Search code examples
.netassembliesilaspnet-compiler

How can I rename[space] a type in a .NET assembly


Given some assembly with some type in it, how can rename and renamespace that type so its in a different location? Or perhaps just extract the type and move it to a different assembly.

Are there any tools out there to do this? (Cecil?) And are there any tuts for said tool?

Thanks

Background to dispel "why are you doing that, idiot?!" responses:

I'm precompiling my views in a web application, then ILMerging the assemblies together. I'm using a custom virtual path provider to load views from many physical and virtual locations (some precompiled, some not). The precompiled views have "incorrect" names and namespaces so I need to correct this. (Unless there is a way to make aspnet_compiler not mess the names and namespaces up in the first place? Also, I'm aware I could make my VPP search for the views in their modified namespace, thats not the point.


Solution

  • Worked it out using Cecil.

    Here is a post on it: How to modify .NET types’ names and namespaces inside compiled assemblies using Mono.Cecil