本文介绍了添加对System.CodeDom.Compiler.CompilerParameters的activex引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿......

i使用此代码在运行时编译源代码。

hey ...
i used this code to compile a source in run time.

 Microsoft.CSharp.CSharpCodeProvider cscp = new Microsoft.CSharp.CSharpCodeProvider();
 System.CodeDom.Compiler.CompilerParameters cp = new System.CodeDom.Compiler.CompilerParameters();

cp.ReferencedAssemblies.Add("System.dll");
cp.ReferencedAssemblies.Add("AxInterop.MSTSCLib.dll");
cp.ReferencedAssemblies.Add("Microsoft.CSharp.dll");
cp.ReferencedAssemblies.Add("Interop.MSTSCLib.dll");
cp.GenerateInMemory = false;
cp.GenerateExecutable = true;
cp.OutputAssembly = "chilProgram.exe";
System.CodeDom.Compiler.CompilerResults cr = cscp.CompileAssemblyFromSource(cp,"SomeCodeToCompile");





一切都很好,但是当我运行子程序时,它会给我这个名为Interop.MSTSCLib的activex控件的错误.dll:



everything is good , but when i run the child program it will give me this error for activex control named "Interop.MSTSCLib.dll" :

Unhandled exception : System.BadImageFormatException : Could not load file or assembly 'Interop.MSTSCLIP, Version=1.0.0.0 ,Culture neutral, PublicKeyToken=null' or one of dependencies. An attempt was made to load a program with an incorrect format.





有什么问题?关于PublicKeyToken = null可能有问题吗?或者向引用添加activex控件有另一种方法吗?

< edit>我有新错误我无法调用dll中的任何属性

非常感谢!



what is the problem? is it possible problem be about PublicKeyToken=null? or adding a activex control to references has another way?
<edit> i have new error i cant invoke any property in the dll
very thanks!

推荐答案


这篇关于添加对System.CodeDom.Compiler.CompilerParameters的activex引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 21:46