.Net反射问题 [英] .Net Reflection Problem

查看:62
本文介绍了.Net反射问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,到目前为止,这个问题一直很明显,所以我希望这里有人可以帮助我.

我有以下代码可以后期绑定到VB6 DLL(通过类型库导入程序创建的包装器)
*请注意,出于本文的目的,以下代码已删除所有错误处理等信息.

O.k, this problem has been very evasive so far so I''m hoping someone here could help me.

I have the following code to late bind to a VB6 DLL (via a wrapper created by the Type Library Importer)
* Note the following code has been stripped of all error handling etc. for the purpose of this post.

FileInfo _library = new FileInfo(filePath);
Assembly _assembly = Assembly.LoadFile(_library.FullName);
var tn = _assembly.GetTypes().Where(p=>p.FullName.EndsWith("CommsClass")).SingleOrDefault();
string typeName = tn.ToString();
Type _classType = _assembly.GetType(typeName);
object _classObject = Activator.CreateInstance(_classType);



在某些机器上(通常是程序员诅咒"),而不是在我的机器上,此代码在最后一行崩溃,但以下情况除外:



On some machines, and typically as the "programmers curse" would have it, not on MY machine, this code crashes on the last line with the following exception:

Error creating an instance of the object type: wr_TCPIP_ASTM.TCPIP_ASTM_CommsClass Creating an instance of the COM component with CLSID {27CC4E03-D86D-40B5-96D4-F7EA5B148A0D} from the IClassFactory failed due to the following error: 800a0153.



就像我说的那样,我第一次在生产系统上看到此错误,尝试以管理员身份登录,没有任何区别.所有Windows更新,框架和Service Pack都是最新的.

包装DLL和原始DLL都位于它们所属的文件系统上.我可能会提到VB6 DLL引用了一个系统DLL,在这种情况下,它是WINSCK.OCX,但是在其他一些出现相同问题的DLL中,我引用了MSCOMM32.OCX.



Like I said, I saw this error for the first time on a production system, tried logging in as Administrator, made no difference. All windows updates, frameworks and service packs are current.

Both the wrapper DLL and the original DLL are located on the file system where they belong. I might mention that the VB6 DLL references a system DLL, in this case it''s the WINSCK.OCX, but in some other DLL''s that give the same problem I reference MSCOMM32.OCX.

Any ideas at all?

推荐答案

,您知道哪个dll/ocx/exe实现了对象wr_TCPIP_ASTM.TCPIP_ASTM_CommsClass(27CC4E03-D86D-40B5-96D4-F7EA5B148A0D)吗? br/>
您可以使用regedit来查找-在类root
下 HKEY_CLASSES_ROOT找到wr_TCPIP_ASTM.TCPIP_ASTM_CommsClass
在wr_TCPIP_ASTM.TCPIP_ASTM_CommsClass下应为CLSID
复制CLSID的内容,然后找到它作为键
找到密钥后,它将为您提供软件无法在生产环境中加载的dll/ocx/exe路径


上面的过程将检查com对象是否已注册,还检查注册路径中是否有某些内容

如果所有这些都正确,那么我认为您在生产环境中一定有安全问题.
do you know which dll/ocx/exe implements the object wr_TCPIP_ASTM.TCPIP_ASTM_CommsClass (27CC4E03-D86D-40B5-96D4-F7EA5B148A0D)?

You can find out using regedit - under classes root
HKEY_CLASSES_ROOT find wr_TCPIP_ASTM.TCPIP_ASTM_CommsClass
under wr_TCPIP_ASTM.TCPIP_ASTM_CommsClass should be CLSID
Copy the contents of CLSID then find it as a key
Once you have found the key it will give you the path to the dll/ocx/exe that your software is failing to load in the production environment


The above process will check that the com object is registered, also check the there is something located in the registered path

If all this is correct then I think you must have a security issue in the production environment.


在Component Service中的COM +应用程序中注册组件可以解决此问题.
Registering the components in a COM+ application in Component Service fixed this.


这篇关于.Net反射问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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