我的vb.net代码在部署时无法调用VB6 DLL [英] My vb.net code can not Call my VB6 DLL when deployed

查看:193
本文介绍了我的vb.net代码在部署时无法调用VB6 DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码创建了对vb6 dll的引用,并使用该引用来调用该对象。我有一个问题,因为在Debug和我的机器上它的作品很棒。但是当我将其部署到Windows 2008 64 Server的服务器时,它不起作用。



我收到此错误:由于以下错误,检索CLSID组件的COM类工厂{C259F578-EC04-4C0F-A13B-AA440F13CB73}失败:80040154类未注册(HRESULT异常:0x80040154(REGDB_E_CLASSNOTREG))



这是我的代码。

  ClasstoInstantiate = ExportObject 
如果UCase(pRow(TypeVB6)。ToString())=TRUE然后
classType = Type.GetTypeFromProgID(ClasstoInstantiate,True)
Else
classType = Type.GetType(ClasstoInstantiate,True)
End If

Dim o As Object = Activator.CreateInstance(classType)


解决方案

VB6只能构建32位dll。如果您的VB.Net代码是为任何CPU构建的,那么它将作为64位系统上的64位应用程序运行,无法看到32位的COM对象。将您的程序集从VB.Net重新定位到x86平台。它应该以32位进程开始,然后在x64系统上启动,并且可以看到32位com对象。



还要确保使用正确的regsvr32命令regsiter您的vb6对象。 64位系统上有2种不同的版本。一个在%systemroot%\system32(64位版本)和%systemroot%\SysWOW64(32位)。您应该使用64位com对象/ dll上的system32版本和32位com对象/ dll的SysWOW64版本。


I have some code that creates a reference to a vb6 dll and Uses that reference to call the object. I am having a problem because in Debug and on my machine it works great. But when i deploy it to the server which is a windows 2008 64 Server it doesn't work.

I get this error: "Retrieving the COM class factory for component with CLSID {C259F578-EC04-4C0F-A13B-AA440F13CB73} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."

Here is my code.

    ClasstoInstantiate = ExportObject
    If UCase(pRow("TypeVB6").ToString()) = "TRUE" Then
        classType = Type.GetTypeFromProgID(ClasstoInstantiate, True)
    Else
        classType = Type.GetType(ClasstoInstantiate, True)
    End If

    Dim o As Object = Activator.CreateInstance(classType)

解决方案

VB6 is only going to be able to build 32bit dlls. If your VB.Net code is built for ANY CPU then it is going to run as a 64bit app on a 64bit system and cannot see the 32bit com object. Retarget your assembly from VB.Net to the x86 platform. It should start as a 32 bit process then on the x64 system and be able to see the 32bit com object.

Also make sure that you are using the correct regsvr32 command to regsiter your vb6 object. There are 2 different versions on 64bit systems. One in %systemroot%\system32 (64bit version) and %systemroot%\SysWOW64 (32bit). You should use the system32 version on 64bit com objects/dlls and the SysWOW64 version of 32bit com objects/dlls.

这篇关于我的vb.net代码在部署时无法调用VB6 DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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