Код: Выделить всё
CSharpCodeProvider codeProvider = new CSharpCodeProvider();
ICodeCompiler icc = codeProvider.CreateCompiler();
string Output = "program.exe";
System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
parameters.ReferencedAssemblies.Add("System.dll");
parameters.GenerateExecutable = true;
parameters.OutputAssembly = Output;
CompilerResults results = icc.CompileAssemblyFromSource(parameters, codeCompile);
Команду я тоже нашел
Код: Выделить всё
C:\winsdk61>mt.exe -nologo -manifest "r:\shared\hl.exe.manifest" -updateresource:"r:\shared\hl33m.exe;#1"
Я не могу точно понять, как и на каком этапе мне следует подать заявку это, учитывая имя моего файла манифеста и приведенный выше код компиляции.
Я попробовал этот вариант
Код: Выделить всё
//Add an application manifest using mt.exe
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = Path.Combine( System.Web.HttpContext.Current.Server.MapPath( "~/Content/" ), "mt.exe" );
string AppManifestPath = Path.Combine( System.Web.HttpContext.Current.Server.MapPath( "~/Content/" ), "CustomInstaller.exe.manifest" );
startInfo.Arguments = string.Format( "-nologo -manifest \"{0}\" -outputresource:\"{1};#1\"", AppManifestPath, cp.OutputAssembly );
process.StartInfo = startInfo;
process.Start();
process.WaitForExit( 10000 ); //wait until finished (up to 10 sec)
Код: Выделить всё
CSharpCodeProvider codeProvider = new CSharpCodeProvider();
ICodeCompiler icc = codeProvider.CreateCompiler();
string Output = "program.exe";
System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
parameters.ReferencedAssemblies.Add("System.dll");
parameters.EmbeddedResources.Add(@"WindowsProcessDll.dll");
parameters.GenerateExecutable = true;
parameters.OutputAssembly = Output;
//Add an application manifest using mt.exe
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = Path.Combine("MY_PATH\\mt.exe");
string AppManifestPath = Path.Combine("MY_PATH\\app.manifest");
startInfo.Arguments = string.Format("-nologo -manifest \"{0}\" -outputresource:\"{1};#1\"", AppManifestPath, parameters.OutputAssembly);
process.StartInfo = startInfo;
process.Start();
process.WaitForExit(2000); //wait until finished (up to 10 sec)
CompilerResults results = icc.CompileAssemblyFromSource(parameters, codeCompile);
"System.ComponentModel.Win32Exception" в System.dll
Что я делаю не так?
Подробнее здесь: https://stackoverflow.com/questions/790 ... ynamically
Мобильная версия