We help IT Professionals succeed at work.

Referencing Legacy COM via Interop in VB.NET

1,803 Views
Last Modified: 2013-12-08
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!).
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
What kind of COM DLL is it?

Bob

Author

Commented:
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


Author

Commented:
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?
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
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.

Author

Commented:
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.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.