添加对System.CodeDom.Compiler.CompilerParameters的activex引用 [英] Add a activex reference to System.CodeDom.Compiler.CompilerParameters

查看:93
本文介绍了添加对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!

推荐答案

您好,



BadImageFormatException通常表示64比32比特冲突。检查是否所有程序集都设置为特定格式。如果您正在调用为不同平台编译的COM或DLL,也会发生此错误,例如,您从64位系统上的程序集调用32位COM / DLL,其中程序集的平台默认为x64 。



问候,
Hello,

BadImageFormatException usually means 64 vs 32 bit conflict. Check whether all of the assemblies are set to a particular format. This error can also occurr if you''re calling a COM or a DLL which is compiled for different platform, for example you call 32 bit COM/DLL from an assembly on a 64 bit system where assembly''s platform would default to x64.

Regards,


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆