Link to home
Start Free TrialLog in
Avatar of darcher23
darcher23

asked on

Referencing Legacy COM via Interop in VB.NET

Hi Experts,

I'm migrating some VB.NET development work to a Vista machine.  As a result, a legacy COM DLL I reference within the code to create an interop interface (SAP library LIBRFC32.DLL) is not compatible with Vista and will not register (hence I can't get my project to build).

I don't really care if the library actually works on my machine (as long as it works on the deployed client), as it's really about creating the COM interop.

Has anyone come across this problem, and can suggest a workaround (apart from ditch Vista!).
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

What kind of COM DLL is it?

Bob
Avatar of darcher23
darcher23

ASKER

It is remote function library for SAP.  I use it to pop an SAP session together with a customer ID so that the user can interact directly with SAP from my application.  The declaration code is:

    ' Extended RFC functions - 32-bit version - Need to make sure LIBRFC32.DLL is installed/referenced by the application
    Declare Function RfcOpenExt Lib "librfc32.dll" (ByVal destination As String, ByVal Mode As Short, ByVal hostname As String, ByVal Sysnr As Short, ByVal gwhost As String, ByVal gwservice As String, ByVal Client As String, ByVal user As String, ByVal password As String, ByVal language As String, ByVal Trace As Short) As Integer
    Declare Function RfcOpenExtV3 Lib "librfc32.dll" (ByVal destination As String, ByVal Mode As Short, ByVal hostname As String, ByVal Sysnr As Short, ByVal gwhost As String, ByVal gwservice As String, ByVal Client As String, ByVal user As String, ByVal password As String, ByVal language As String, ByVal Trace As Short, ByVal use_load_balancing As Short, ByVal lb_host As String, ByVal lb_system_name As String, ByVal lb_group As String, ByVal use_sapgui As Short) As Integer
    Declare Sub RfcClose Lib "librfc32.dll" (ByVal hRfc As Short)

    Declare Function RfcCallExt Lib "librfc32.dll" (ByVal hRfc As Integer, ByVal hSpace As Integer, ByVal funcname As String) As Integer
    Declare Function RfcReceiveExt Lib "librfc32.dll" (ByVal hRfc As Integer, ByVal hSpace As Integer, ByVal exception As String) As Integer
    Declare Function RfcCallReceiveExt Lib "librfc32.dll" (ByVal hRfc As Integer, ByVal hSpace As Integer, ByVal funcname As String, ByVal exception As String) As Integer

    Declare Function RfcAddExportString Lib "librfc32.dll" Alias "RfcAddExportParam" (ByVal hSpace As Integer, ByVal parpos As Integer, ByVal parname As String, ByVal parnamelen As Integer, ByVal partype As Integer, ByVal parlen As Integer, ByVal par As String) As Integer

    Declare Function RfcAllocParamSpace Lib "librfc32.dll" (ByVal numexp As Short, ByVal numimp As Short, ByVal numtab As Short) As Integer
    Declare Function RfcFreeParamSpace Lib "librfc32.dll" (ByVal hSpace As Integer) As Integer

    'UPGRADE_WARNING: Structure POINTAPI may require marshalling attributes to be passed as an argument in this Declare statement. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
    Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As Integer
    'UPGRADE_WARNING: Structure POINTAPI may require marshalling attributes to be passed as an argument in this Declare statement. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
    Declare Function ScreenToClient Lib "user32" (ByVal hWnd As Integer, ByRef lpPoint As POINTAPI) As Integer
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As Integer) As Integer


As an after thought, can you actually use the resulting Interop created from another dev machine (i.e. on my Win XP machine, the build creates Interop.IRFC32Lib.dll) in place of the DLL reference?
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Bob,

I haven't seen this resource before.  It might just work with minimal effort as you don't need to install the DLL on the development machine.  I'll dig in over the next day or so to see if this is possible.

Thanks!!

Dave.
Hi Bob,

Just as explanation to the above, I investigated the connector, however it looked a massive job to re-write the project I have had working for a good number of years.  The real issue here is that the SAP DLL is just not compatible with Vista (sigh).

My fix has been to have a Win XP build machine - I am still able to develop on the Vista box, but I can't generate a build without issues.

Thanks again for the 'out-of-the-box' suggestions.

Cheers,
Dave.