Tag: csharpcodeprovider

如何为从源文件编译的应用程序分配自定义图标?

在我的程序中,我使用CSharpCodeProvider来从源文件编译另一个应用程序,我使用的代码如下: public static bool CompileExecutable(String sourceName) { FileInfo sourceFile = new FileInfo(sourceName); CodeDomProvider provider = null; bool compileOk = false; // Select the code provider based on the input file extension. if (sourceFile.Extension.ToUpper(CultureInfo.InvariantCulture) == “.CS”) provider = CodeDomProvider.CreateProvider(“CSharp”); else if (sourceFile.Extension.ToUpper(CultureInfo.InvariantCulture) == “.VB”) provider = CodeDomProvider.CreateProvider(“VisualBasic”); else { Console.WriteLine(“Source file must have a .cs or […]

使用带有.net 4.5 beta的CSharpCodeProvider

我最近安装了Visual Studio 11 Beta,我正在尝试更新现有的4.0项目以使用4.5。 在程序中,它使用CSharpCodeProvider编译一些动态生成的代码。 /// /// Compile and return a reference to the compiled assembly /// private Assembly Compile() { var referencedDlls = new List { “mscorlib.dll”, “System.dll”, “System.Core.dll”, }; referencedDlls.AddRange(RequiredReferences); var parameters = new CompilerParameters( assemblyNames: referencedDlls.ToArray(), outputName: GeneratedDllFileName, // only include debug information if we are currently debugging includeDebugInformation: Debugger.IsAttached); parameters.TreatWarningsAsErrors = […]

我们如何将嵌入式资源添加到在运行时从源文件编译的文件中

我正在编写一个小应用程序,它使用函数从源(.cs)代码文件编译文件: public static bool CompileExecutable(String sourceName) { //Source file that you are compliling FileInfo sourceFile = new FileInfo(sourceName); //Create a C# code provider CodeDomProvider provider = CodeDomProvider.CreateProvider(“CSharp”); //Create a bool variable for to to use after the complie proccess to see if there are any erros bool compileOk = false; //Make a name for the […]