开发者

My vb.net code can not Call my VB6 DLL when deployed

开发者 https://www.devze.com 2023-04-09 09:52 出处:网络
I have some code that creates a reference to a vb6 dll and Uses that refe开发者_如何学编程rence to call the object.I am having a problem because in Debug and on my machine it works great.But when i de

I have some code that creates a reference to a vb6 dll and Uses that refe开发者_如何学编程rence 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.


The DLL may be registered on your machine, but not on the server.

You can use REGSVR32 to register the DLL manually.

0

精彩评论

暂无评论...
验证码 换一张
取 消