Hello all,
I am sorry if this question has already been asked. And sorry for the long post.
Here is my problem.
I have a 64-bit vb.net application.
I have a 3rd party 32-bit unmanaged DLL.
I need to establish communication from the 64-bit managed application to the 32-bit unmanaged dll.
Here are the things I've tried:
1. I created a 32-bit vb.net wrapper class library, called COM1, and added a vb.net COM class that calls the 32-bit unmanaged dll's exposed functions.
The project had "Register for COM interop" enabled.
When I referenced the 32-bit DLL (COM1.dll) to my 64-bit application and executed the application, I received the following exception:
"Could not load file or assembly 'COM1.dll'...An attempt was made to load a program with an incorrect format."
2. I created a 64-bit vb.net wrapper class library, called COM2, and added a vb.net COM class that calls the 32-bit unmanaged dll.
The project had "Register for COM interop" enabled.
When I referenced the 64-bit DLL (COM2.dll)to my 64-bit application and executed the application, I was able to load the 64-bit dll but I received the following exception when i called one of the functions exposed in the unmanaged dll (via the 64-bit wrapper dll):
"An attempt was made to load a program with an incorrect format."
I understand that i cannot call a 32-bit dll directly to my 64-bit application.
What I am trying to do is call the 32-bit dll through IPC mechanism; in this case COM.
But, obviously, I am making some mistake here.
I tried the above steps using a WCF application as well where i replace the COM wrapper with the WCF service.
But I get the same result.
Can someone give me a working code or tell me what am I doing incorrect in the above-mentioned steps?
Thank you for reading and giving your time.
Really appreciate your help.
Regards.
What I have tried:
'My COM class
<comclass(comclass1.classid, comclass1.interfaceid,="" comclass1.eventsid)=""> _
Public Class ComClass1
Public Declare Sub InitializePort Lib "I2CDrvrs" (ByVal I2cAddr As Byte, ByVal evalBoardUsed As Byte)
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "bd248311-07ca-4d09-a5d1-d4c6b4df0256"
Public Const InterfaceId As String = "f8de730a-d845-44c3-b029-fc556d2e7f0c"
Public Const EventsId As String = "abaf2635-6f30-46f7-a7a9-5a44bef46f9b"
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub
End Class
'My 64-bit application
Public Function foo() As Boolean
Try
COM1.ComClass1.InitializePort(2, 2)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Return True
End Function