Saving Types generated via Reflection.Emit as code file (.cs) instead of saving it in .dll files

Posted by Manish Sinha on Stack Overflow See other posts from Stack Overflow or by Manish Sinha
Published on 2010-04-03T15:43:53Z Indexed on 2010/04/03 15:53 UTC
Read the original article Hit count: 315

Before start let me tell my experience: I am experienced with C#.NET, web services, XML part and few more. Reflection is something new to me, though I have read extensively on it and tried out some experimental code, but haven't made anything great using reflection

I checked out many examples of how we can create Type at runtime and then which can be saved in an assembly (.dll) files. Of all the examples I have seen is about saving the created types in the .dll files instead of code file. Isn't there any way to create the code file out of reflection?

I need to create code file since I want to distribute code instead of compiled assemblies. What I want to do is something like xsd.exe does, either spit out a .dll or the code file(in any language).

Isn't there any way to create a code file, since most of the place I can find is

AssemblyBuilder ab = System.AppDomain.CurrentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.Save);

and then lastly

ab.Save("QuoteOfTheDay.dll");

© Stack Overflow or respective owner

Related posts about c#

Related posts about reflection