codedom

CompileAssemblyFromDom (CodeDom compiler) generates line numbers differently than visual studio

I am using the CodeDOM to generate and compile an assembly. I have found that if the generated code does not compile, the CompileAssemblyFromDom method generates line numbers that are different than what visual studio would generate. So for example, if I call GenerateCodeFromCompileUnit on the code provider, take the generated code in...

CSharpCodeProvider output .NET 2.0 assembly from .NET 4.0 application

I'm using the CSharpCodeProvider to compile a CodeDom object into an assembly. The application itself is running under .NET 4.0. However I need the output from CompileAssemblyFromDom to build against .NET 2.0 for compatibility with some external resources. How can I tell the CSharpCodeProvider to build against .NET 2.0? ...

Change Generated C# Class Name

I am using ManagementClass.GetStronglyTypedClassCode to get a reference to CodeTypeDeclaration instance. I would like to change the generated class name and this method doesn't allow for this (as far as I can tell). I have tried to change the CodeTypeDeclaration.Name property, but this doesn't change constructor names etc, so the C# comp...

C# - CodeDOM Question

Hey, I'm new to using codedom. Can someone tell me how to convert this code to be run in C#? Code: WebClient webClient = new WebClient(); webClient.DownloadFile("http://mysite.com/myfile.txt", @"c:\myfile.txt"); Thanks. ...

using CodeDom to generate an enum with Value as well as Name

Hello, I have this little piece of code : private Dictionary<string, IList<KeyValuePair<int, string>>> EnumsCollection = new Dictionary<string, IList<KeyValuePair<int, string>>>(); // ...... Dictionary is filled, fine // ... outer loop foreach (var enumNameAndValue in EnumsCollection[enumName]) { var code...

CodeDom and Silverlight

Can Silverlight apps (the .xap file, the testpage.html, content resources along side a ClientBin, out of browser settings, etc) be created using only System.CodeDom from a regular .NET app? Meaning I have a console or winforms app that creates Silverlight apps - is this possible with System.Codedom? I have searched high and low and have...

Compiling source code in debug mode using a CodeDomProvider

I have some source code I'd like to compile using the Microsoft.CSharp.CSharpCodeProvider class, and I want to include stuff that's specific to debug builds (e.g., methods marked with the [Condtional("DEBUG")] attribute). I tried setting the CompilerParameters.CompilerOptions property to "/debug", but when I ran the compiled code the de...

Add WebService attributes to a class generated with CodeDom

I am using CodeDom to generate the c-sharp class for an ASMX webservice, but I'm having trouble adding the web service attributes to the class. I am trying to get the following end-result: [WebService(Namespace = "http://schemas.me.com/mywebservice/", Name = "MyWebService")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] ...