Welcome to Forums Sign in | Join | Help | Forums
in Search


Unable to run the RE:API in .NET Application

Last post 12-09-2009 4:25 AM by David Zeidman. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 12-01-2009 10:45 AM

    Unable to run the RE:API in .NET Application

    When i running the my sample application i get the following error.

    Startup Error: Failed to load control 'WebHost' from RE7_WEBHOST72.OCX.  Your version of RE7_WEBHOST72.OCX may be outdated.  Make sure you are using the version of the control that was provided with your application.

     
    Main Startup Step: CBBStartSeq.Startup
     
    Start Sequence Step: ShowSplash
     
    Can any one help in this regard.
     
    The sample code which i written is
     
    Dim RE7 As REAPI = New REAPI()

    ' Initialize the API

    If RE7.Init("WRE11111") Then

    Console.WriteLine("API Initialized!")

    ' Create an instance of RE's Funds Collection Class

    Dim oFunds As New CFunds()

    oFunds.Init(RE7.SessionContext)

    Dim oFund As CFund

    ' Iterate over all funds in the system

    For Each oFund In oFunds

    ' Print the description of each fund to the console

    Console.WriteLine("Fund: " & oFund.Fields(EfundFields.Fund_fld_DESCRIPTION))

    ' Free up any resources held by this object

    oFund.CloseDown()

    Next oFund

    ' Free up any resources held by this object

    oFunds.CloseDown()

    Else

    Console.WriteLine("Unable to initialize. " & "Error code = " & RE7.SessionContext.ErrorObject.ErrorDescription())

    Exit Sub

    End If

     

     

     

     

    Filed under:
  • 12-08-2009 5:10 AM In reply to

    • Paul Ward
    • Not Ranked
    • Posts 8
    • Organization: CCR Data Limited

    Re: Unable to run the RE:API in .NET Application

    Hi Virginia,  

    Interesting ....

     I'm having the exact same problem, let me guess it trips up when you call RE7.Init("Serial")

    I've been talking to one of the API support guys now for about a week, bouncing emails to and fro, I'm guessing that like me you can login normally to the db in question (through RE) and that you have activated the module using an API unlock code already?

    Brian Mickle sent me a little app today which was apparently designed to test that the API was connectable and that passed perfectly fine.

     ...

    I've tried :

    • Reinstalling RE from scratch (Version 7.91.36).
    • Testing against another db.
    • Recompiling my code against other versions of .net (My project is in C# by the way).
    • Logging in as usual.
    • Testing with Brians little Test App.
    • Reinstalling everything microsoft (.NET, SQL Server, ect) ...
    • Checking versions of the ocx files against a working server (matched perfectly).

    Any other ideas or tests you know of ?

  • 12-08-2009 5:22 AM In reply to

    • Paul Ward
    • Not Ranked
    • Posts 8
    • Organization: CCR Data Limited

    Re: Unable to run the RE:API in .NET Application

    In case anyone else comes across this error this is what it looks like :

  • 12-08-2009 12:24 PM In reply to

    • Paul Ward
    • Not Ranked
    • Posts 8
    • Organization: CCR Data Limited

    Solved !!!

    Ok so the problem is described above.

    And the API says that it can't create this ActiveX control for some reason.

    ...

    A little digging around will reveal that Active X controls need to be created within the context of a "Parent Window" which means you need a Windows Forms object which has been fully initialised before you can make this call.

    Basically to replicate the problem create a new winforms app then in the constructor for "Form1" add this code (C# version):

    REAPIClass api = new REAPIClass();

    MethodInfo mi = typeof(REAPIClass).GetMethod("Init");

    // this call causes the error

    mi.Invoke(api, new Object[] { "Serial_number", Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value });

     VB would look something like this :

    REAPIClass api = new REAPIClass()

    api.Init("Serial_number")

    ....

     Now add a button to the form and move the above code in to the "OnClick" handler for the button.

    Upon clicking the button the issue has seemingly gone away.

    ....

    Personally I would suggest that this is a bug but how else would you otherwise get the login dialog to appear ... so its almost common sense that this API is used within the context of a parent windows form.

    It just means you can't get stuck in to the API too soon !!!

     DOH !!!

  • 12-09-2009 3:54 AM In reply to

    • Paul Ward
    • Not Ranked
    • Posts 8
    • Organization: CCR Data Limited

    Re: Solved !!!

    It might be worth noting that if you created your own login dialog you could make the call in to the API with all the params provided, this would mean that the control in question would not be needed and thus not be called.

     It's a bit of a headache but it's another option that people can look in to.

  • 12-09-2009 4:25 AM In reply to

    • David Zeidman
    • Top 25 Contributor
    • User Since: 2002
    • Posts 326
    • Organization: Zeidman Development
    • Products:  Blackbaud Direct Marketing, Blackbaud Enterprise CRM, The Information Edge, The Raiser's Edge

    Re: Solved !!!

    Your easiest solution is to just call

    OLEInitialize(Nothing)

    This needs to be declared as follows:

    Public Declare Function OLEInitialize Lib "ole32" Alias "OleInitialize" (ByVal intp As IntPtr) As Integer

    David

    David Zeidman
    Zeidman Development
    http://www.zeidman.info

    Check out my RE API blog
    http://www.re-decoded.com
Page 1 of 1 (6 items)