Import librfc32.dll by reflection

Hi .net Specialists,
hope anyone can help.
I`d like to connect a external program with SAP. The external program provides a scripting interface to add custom VB.NET code. But it`s not possible to add own assembly references.
The program vendor told me, that the only way to use custom dll`s are to use the system.reflection function.
Did anyone know how this reflection function works and how i can use the librfc32.dll with this function?
Thanks,
Anton

Hi,
You should probably be using the SAP.Connector.dll and SAP.Connector.Rfc.dll assemblies, not the librfc32.dll by itself... At least, it will be way easier.
You need to put those 2 dlls in your Global Assembly Cache, or in the project's folder (either as reference, easier, or just the files). The "librfc32.dll" itself needs to be in the project's folder (with the .exe.).
I tested this (since I was curious) and you can just put the 3 dlls in your application folder, it works fine.
Once that is done, if you still need to load through reflection, google it, there's plenty of examples on the .Net. Basically, it works like this. I tested this code on a Windows 7 64 bit, without VS.NET 2003/2005 and without the .NET connector installed and it works.
// load assembly
System.Reflection.Assembly assm = System.Reflection.Assembly.LoadFrom("SAP.Connector.dll");
// define the client type
System.Type sapClientType = assm.GetType("SAP.Connector.SAPClient", true);
System.Type sapConnectionType = assm.GetType("SAP.Connector.Connection", true);
// initialize a client
object oSAPClient = System.Activator.CreateInstance(sapClientType);
// open the connection
System.Reflection.PropertyInfo connectionProp = sapClientType.GetProperty("Connection");
System.Reflection.PropertyInfo connectionStringProp = sapClientType.GetProperty("ConnectionString");
connectionStringProp.SetValue(oSAPClient, "AHOST=123...", null);
object conn = connectionProp.GetValue(oSAPClient, null);
System.Reflection.MethodInfo connectionOpen = sapConnectionType.GetMethod("Open");
object result = connectionOpen.Invoke(conn, null);
// do your stuff
// close the connection
System.Reflection.MethodInfo connectionClose = sapConnectionType.GetMethod("Close");
connectionClose.Invoke(conn, null);
Doing this is not trivial and requires a lot of effort. But you asked, so there you go!
Regards,
Michel
P.S. This is c# code, but VB.NET is very similar, only syntax is different but the logic is the same.
Edited by: Michel Roberge on Nov 18, 2010 8:23 PM
Edited by: Michel Roberge on Nov 18, 2010 9:09 PM

Similar Messages

  • SAP librfc32.dll

    How critical is it to use the librfc32.dll version (file version 4640,5,123,2956) referred to in the OWB 9.2 User Guide? I can't find this exact version and I have no errors when creating a SAP source module. However, when I try to import tables from SAP by browsing Business Component, the loading progress dialog disappears after 1 second and a blank SAPR/3 Business Component Hierarchy view opens.
    Even if I remove the librfc32.dll file from the OWB_HOME\owb\bin\admin location on my client, the above still applies. Should this file be placed somewhere else to make a connection to SAP?

    We are using OWB 9.2.0.2.8 There are many versions of librfc32.dll. Where can I find the exact version mentioned in the user guide, if this is critical?
    The user guide says this dll should be placed in OWB_HOME/bin/admin. On my installation I have either OWB_HOME/bin with no /admin sub-directory, or I have OWB_HOME/owb/bin/admin. I assume the latter directory location is the correct location for the dll (or do I need to create a new admin sub-directory under OWB_HOME/bin?).

  • How do I use "LabVIEW dll import wizard" to import NETAPI32.dll

    I am trying to use the LabVIEW dll import wizard for the first time. I am not very familiar in C-coding so this might be a good help instead of configuring CallLibraryFunction nodes myself.
    I want to import NETAPI.dll. I am interested in several functions in that dll, but my main priority is the funtion NetUserGetInfo(). On MSDN I have found that the header file for the mentioned function should be: lmaccess.h (include lm.h).
    My problem is this:
    The shared library contains 317 function(s). But no function is found and recognized in the header file. The following function(s) cannot be wrapped. If you want to import these functions, please review the warning messages next to the functions below. You will need to fix the problems before you can continue with the wizard.
    The function cannot be imported into LabVIEW. This might be caused by one of the following problems:
    The function is not declared in the header file but is exported in the library.
    Check the header file to make sure it contains declarations of the function.
    Undefined symbols can prevent the wizard from recognizing functions and parameters. To correct this problem, check the header file to determine if you must add predefined symbols. Click the Back button to return to the previous page of the wizard to add a predefined symbol (for example, "NIAPI_stdcall = __stdcall" or "NIAPIDefined = 1").
    MIDL_PASS;_STDCALL_SUPPORTED;__cplusplus;
    Any suggestions how I can solve my issue?   

    astrid wrote:
    I am trying to use the LabVIEW dll import wizard for the first time. I am not very familiar in C-coding so this might be a good help instead of configuring CallLibraryFunction nodes myself.
    I want to import NETAPI.dll. I am interested in several functions in that dll, but my main priority is the funtion NetUserGetInfo(). On MSDN I have found that the header file for the mentioned function should be: lmaccess.h (include lm.h).
    My problem is this:
    The shared library contains 317 function(s). But no function is found and recognized in the header file. The following function(s) cannot be wrapped. If you want to import these functions, please review the warning messages next to the functions below. You will need to fix the problems before you can continue with the wizard.
    The function cannot be imported into LabVIEW. This might be caused by one of the following problems:
    The function is not declared in the header file but is exported in the library.
    Check the header file to make sure it contains declarations of the function.
    Undefined symbols can prevent the wizard from recognizing functions and parameters. To correct this problem, check the header file to determine if you must add predefined symbols. Click the Back button to return to the previous page of the wizard to add a predefined symbol (for example, "NIAPI_stdcall = __stdcall" or "NIAPIDefined = 1").
    MIDL_PASS;_STDCALL_SUPPORTED;__cplusplus;
    Any suggestions how I can solve my issue?   
    Sorry I forgot the attachment, but here it is.
    Attachments:
    NETAPI32.doc ‏103 KB

  • Unable to load DLL 'librfc32.dll'  (Exception from HRESULT: 0x8007007E)

    Unable to load DLL 'librfc32.dll'  (Exception from HRESULT: 0x8007007E)
    Hi!
    We would like to hold the account balance data from EMPTOR to SAP and have the following error:
    Unable to load DLL 'librfc32.dll'  (Exception from HRESULT: 0x8007007E)
    We use SAP ERP 2005 on Windows 64 Bit.
    Can some one help with the problem?
    Thank you very much!
    regards
    Thom

    You can download the latest avaiable kernel or just the librrfc component from http://service.sap.com/swdc. They maybe an issue with this DLL. Just download the latest one and copy into \usr\sap\<SID>\SYS\exe\run directory. Be sure to save the previous DLL.
    Thanks
    Adil

  • Microsoft Visual Studio - Unable to load DLL 'librfc32.dll'

    Hi,
    I'm experiencing the following problem:
    When trying to establish a connection between SAP BPC MS and our SAP NW BW system.
    I've created a new Integration Services project in Business Intelligence Development Studio. The issue comes up when I try to test the connection:
    TITLE: Microsoft Visual Studio
    Unable to load DLL 'librfc32.dll':
    This application has failed to start because the application configuration is incorrect.
    Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)
    I've placed the librfc32.dll library file on C:\WINDOWS\system32\.
    I ran R3DLLINS.EXE according to Note 684106 - Microsoft runtime DLLs.
    This placed all the needed dll library files (msvcr71.dll, msvcp71.dll, mfc71.dll, mfc71u.dll) on the correct path (C:\WINDOWS\system32\).
    I keep getting the same error.
    Platform:
    Windows 2003 R2 SP2 32-Bit
    MS SQL Server 2008 SP1
    SAP BPC 7.0 Microsoft Platform
    I've checked out some other posts on SDN but it didn't solve my problem:
    Re: librfc32.dll not found on Windows Server 2003
    LIBRFC32.DLL not Found Error
    Re: librfc32.dll
    Any ideas?
    Thank you.
    Bruno Pereira
    Edited by: Bruno Pereira on Mar 23, 2010 5:34 PM
    Edited by: Bruno Pereira on Mar 23, 2010 5:36 PM

    I was able to work it out.
    For your reference:
    Issue arrises from the fact that Business Intelligence Development Studio isn't able to load the librfc32.dll without the [Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package ATL Security Update |http://www.microsoft.com/downloads/details.aspx?familyid=766a6af7-ec73-40ff-b072-9112bab119c2&displaylang=en#filelist]implemented on the system.
    Reference SAP note:
    [Note 684106 - Microsoft runtime DLLs|https://service.sap.com/sap/support/notes/684106]
    Bye!
    Bruno Pereira

  • Importing Vb Dll in Oracle Forms 6i

    If any one have idea importing vb dll in oracle forms 6i. If any one have idea to Use ORA_FFI package or any other way.

    The Forms Builder Help is the best source of information. It has plenty of examples too, like this one I copied from the Help:
    /* Find foreign library handle for
       a given library name */
    BEGIN
       libhandle := ora_ffi.find_library
                ('mylib.dll');
    END;

  • Import COM.dll in java source?

    Is there a way to import a DLL from a COM-object into java source code? And if so, how does it work?

    I have a COM interface and need to use its methods etc. within Java. My Java program has to access the methods decared in my COM interface. So somehow i have to import it or how does that work?

  • Librfc32.dll exception for ECC 6.0

    Hi,
    My customer just upgraded from SAP R/3 4 to ECC 6.0. All the RFC calls now raise an exception in the librfc32.dll.
    Here is the error from the event viewer:
    Faulting application consoleapplication1.vshost.exe, version 8.0.50727.42, faulting module librfc32.dll, version 7100.0.0.5288, fault address 0x00001c01.
    Is there a braking change in ECC 6.0 RFC protocol? Do I need a new librfc32 dll file? Everything is working from SAP GUI v7.10 and I think that application is using librfc32.dll.
    Any help is much appreciated.
    Best Regards
    Torkel Ödgaard

    Dear Poornima,
    As per my experience,better to go for above 160GB hard drive(250GB will be
    good) and 2 GB RAM is required for Laptop's.
    All the best.
    Regards
    Mangal

  • Missing LIBRFC32.DLL file for 64bit - x64 Windows Server

    Dear Folks,
    I have installed SAP ECC6 with BI7 system on Windows Server 2003 on x64. But I am not able to get data from SAP BW from Crystal Report 2008. I also did  MDX PARSER connection test through t.code SM59. I got list of error messages.
    Logon     Cancel
    Error Details     timeout during allocate / CPIC-CALL: 'ThSAPCMRCV' : cmRc=20 thRc=456 Timeout dur
    Error Details     ERROR: timeout during allocate
    Error Details     LOCATION: SAP-Gateway on host ns2 / sapgw00
    Error Details     DETAIL: no connect of TP mdxsvr from host ns2 after 20 sec
    Error Details     COMPONENT: SAP-Gateway
    Error Details     COUNTER: 798
    Error Details     MODULE: gwr3cpic.c
    Error Details     LINE: 5873
    Error Details     RETURN CODE: 242
    Error Details     VERSION: 2
    I have been read other forums, most probably I am missing LIBRFC32.DLL file for x64 Windows Server. I couldnu2019t find any where this specific file for Windows Server x64 64bit version. It is available on Sap Market place, since I donu2019t have super user rights, I canu2019t download it.
    If any one of you already have this file. Please share with me.
    thanks
    Obaid

    Hello Ingo
    Thanks to read my problem and for your reply, I have already read that SAP Note 1032461,  I  have the same problem as clearly defined in the note, and suggesting to put LIBRFC32.DLL file in <windows-dir>/system32 folder.
    My SAP ECC and BI7 (Kernl 7.00) is installed on 64-bit, x64 Windows Server 2003 Enterprise. I need to download that file from RFC library available on SAP Market place. But, I don't have any super user rights.
    If someone has similar setup and has already that file or could download for me. I need to get that file. I appreciated your kindly help.
    thanks
    Obaid

  • Importing a DLL created with Cygwin

    I am trying to import a DLL created with Cygwin. This is a test DLL created by one of my collegue to validate the import process.
    When I use the import Wizzard, everything run ok. It recognise and build the structure based on the header file.
    When I click ok to generate the wrapper, the progress bar shows but nothing happens. I have to terminate the program (not responding).
    I found in the discussion forum that many users were having similar problem. I also found an interesting article on the subject: http://zone.ni.com/devzone/cda/tut/p/id/5412
    Following this, I reinstalled Cygwin with the packages mentioned in the article :
    gcc
    make
    sharutils
    tclck
    wget
    I also place the Cygwin path in the system path variable. I have also found that if the Cygwin path is not in the system path variable, the wizzard complete ok but the DLL is not able to run (cygwin1.dll is missing).
    Any help will be appreciated.
    RD

    I Claire, I am using Labview 8.6 the demo version.
    What I did is to do a scan of the bulletin board. http://forums.ni.com/ni/board/message?board.id=170​&message.id=384919&requireLogin=False
    I Can't say if this is the same problem I am experiencing but it looks very similar
    I have a Dell Latitude D830
    I have attached a copy of the DLL and an executable that is the core of the DLL.
    Hope this will help you figure it out.
    RD
    Attachments:
    dll.zip ‏4 KB
    test.zip ‏3 KB

  • SAPGui can't start because librfc32.dll is missing

    Dear Experts,
    When I tried to run SAP logon (SAPGui), the following message  appeared,
    "The program can't start because librfc32.dll is missing from your computer"
    even though the librfc32.dll file is in the c:\windows\system32.
    I reregister the dll using regsvr32 c:\windows\system32\librfc32.dll but still the same problem.
    I did try to uninstall and reinstall entire SAPGui but still  the same.
    What else should I try?
    regards,
    Abraham

    I have seen this issue before,
    Install Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package ATL Security Update and re-register the dll that shoudl fix the problem
    You can get it from
    http://www.microsoft.com/downloads/en/details.aspx?familyid=766a6af7-ec73-40ff-b072-9112bab119c2&displaylang=en
    Regards
    Juan

  • Librfc32.dll error

    Dear Experts,
    As per note 1032461 i downloaded and copied the file, But RFC is still showing error. While executed the command "find "LIBRFC" librfc32.dll" and getting the below error.
    As above said in Note:1447900, i cannot find the below files from support portal.
    Solution
    Apply the librfc 7.20 patches level 11 for Windows platforms:
    librfc32.dll  7.20 with file version 7200.1.73.6735 or higher
    librfc32u.dll 7.20 with file version 7200.1.73.6735 or higher

    Brandon,
    My OS is X64 Unicode, i downloaded and copied the below file and it is the latest.
    As per Note:1447900, I needed the:
    librfc32.dll  7.20 with file version 7200.1.73.6735 or higher
    librfc32u.dll 7.20 with file version 7200.1.73.6735 or higher

  • Can not find size_t during import a dll and calling a function crash labview

    Hello, experts
    I need to use FingerLakeInstrument  DLL ( see the attached) inside Labview to talk to a CCD camera. it is built from microsoft visual studio C++
    I unzip FLI dll in my D:\proj\...\linfli-32 and import dll from there. created a c:\FLIDBG.txt as FLI dll needs to write debug message to it if FLISetDebugLevel() or others are called.
    During importing the dll, first thing I got is <sys/types.h>  ( ie size_t ) cannot be found. I have installed free version of microsoft visual studio C++
    but can not find "typedef unsigned int size_t"
    at the end, I just added
     typedef unsigned int size_t;
    in the libfli.h. Having done that, I am able to import all functions into Labview and have a user library called libfli.
    However, as soon as I start calling a simple function in a test.vi, such as FLIGetLibVersion(char* ver, size_t len), which involves nothing other than the library, the labview will crash.
    I created a simple C test.exe which calls many functions without any problem
    any suggstion?
    regards
    xiaofeng
    Solved!
    Go to Solution.
    Attachments:
    libfli-32.zip ‏93 KB

    Hi, Smercurio_fc
    thanks for your reply. Yes, you are pointing to the right place.  I have solved the crash problem.
    when importing DLL into Labview using Tools\import\Shared Library (.dll), Labview automatically set the calling convention as C not as stdcall (WINAPI).  it is this that later the labview crashes when a function is called.  as soon as I manually re-selecte calling convention as stdcall, my test.vi works OK (see attached).
    I tried Call Library Function too to call libfli.dll, as long as I select stdcall as call convetion. the test.vi works.
    How do I know which Call convention I need to choose if  there is no infomation from DLL provider?
    as for the size_t,
    I add   #include <crtdefs.h> in libfli.h and 
     add additional include path as
    C:\Program Files\Microsoft Visual Studio 10.0\VC\include.  this  solved the "not found" issue.
    for this case I know that the DLL is built from VC++,  is this right way? 
    again, thanks for your time.
    xiaofeng
    Attachments:
    test.vi ‏13 KB

  • Librfc32.dll on 2008 R2 64 Bit / IIS crash

    We are currently migrating from Windows Server 2003 32 Bit to 2008 R2 64 Bit(using ERPConnect 4.1. / running IIS 7).
    On 2003 32 Bit every RFC-Call is working fine. But calling SAP under 2008 64 Bit ends in IIS AppCrash.
    The crash possibly caused by an unhandled ABAP exception. This happen randomly.
    Changing the Application to 32 Bit has no effect. Trying several versions of librfc32.dll has no effect.
    Any hints to solve this problem?

    I'm experiencing exactly the same problem. Tried re-installing and re-imaging the box several times. This is the first time I'm running into this issue as I have performed several installs on other Windows 2008 R2 servers with no issues.
    Does anyone have any idea? I opened SR with Oracle, they suggested that this is a bug (This is due to a known issue with older versions of OCM -unpublished bug 9800347 [http://bug.oraclecorp.com/pls/bug/webbug_edit.edit_info_top?rptno=9800347] . This was fixed in 10.3.4 and backported to 10.3.3.1.1; apparently an older version (10.3.3.1) which is bundled in this kit as this OCM 10.3.3.1).
    I'm not buying this explanation as it does not explain why this is happening and why few other times in the past with same system and same version install it worked perfectly fine.

  • Down load librfc32.dll,sapjcorfc.dll and sapjco.jar.

    HI,
    I need copy of files  librfc32.dll,sapjcorfc.dll and sapjco.jar.
    From where can i get all these files.
    Thanks&Regards,
    venkat.

    Hi Venkat.
    I would like to suggest,
    [SAP - Intstallation files - Authentication needed|www.service.sap.com/connectors]
    I would also like to suggest a reference,
    [SAP HELP - Standard Reference - SAP JCo Installation|http://help.sap.com/saphelp_nw04s/helpdata/en/47/80f671ee6e4b41b63c0fe46bd6e4f8/frameset.htm]
    Hope that's usefull.
    Good Luck & Regards.
    Harsh Dave

Maybe you are looking for

  • Have you a simple client for send message on oc4j 9.0.2.0.0 ?

    Hi to All! Have you a simple client to send message on a queue in OC4J 9.0.2 ? Can you show me how is possible to write the config file to connect to oc4j application server? thanks very much Andrea

  • How do I convert a condition integer to an object

    I have a condition integer for conditional text that is applied to text. How do I convert the integer to a Condition Format object? Thanks in advance. Rick Quatro

  • Find out DB- Size in ECC 6.0?

    Hi, I need to find out the DB-Size (or the totaly used space on HDD) of some ECC 6.0  systems. In 4.6C I just looked into the protocoll of the last full backup and searched for the line with "total size". I wonder how to find out total db size in ECC

  • Convert Hpgl file to Pdf

    Hey I need to convert an HPGL file into PDF. I have been looking everywhere- I am working under windows for development though the deployment is under UNIX, so the solution must fit both OS. Someone has an idea how to overcome this issue? Thanks, Nat

  • How to transfer a 2D array from NI-scop into a gray scale image and save it

    Dear all, I acquired a 2D array and want to transfer it into a gray scale image (12 bits) and save it into my hard disk but I don't know how to do it. I can use Intensity graph to show the 2Darray into gray scale image, but the intensity graph.vi can