crdb_adoplus.dll file strangeness


I was running into some problems when trying to use the Crystal Report Viewer in Visual Studio 2010 to view data stored in a local DataSet. After some initial problems with the Database login prompt appearing (you need to set the source with SetDataSource on the report document object, folks), I thought i’d sorted it, until I ran into this:

Could not load file or assembly ‘file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll’ or one of its dependencies. The system cannot find the file specified.

Changing a setting in the app.config file sorted it out. Here’s what I needed to change:

 <supportedRuntime version=”v4.0″ sku=”.NETFramework,Version=v4.0″/>


<startup useLegacyV2RuntimeActivationPolicy=”true”>
 <supportedRuntime version=”v4.0″ sku=”.NETFramework,Version=v4.0″/>

Here’s the MSDN Article that explains the useLegacyV2RuntimeActivationPolicy attribute in more detail:

Whether this causes me headaches further down the development path remains to be seen……

Iterating through open MDIChild forms

I recently had cause to check whether I already had an instance of an MDIChild form open in VB.NET. Using Array.Exists on the MDIChildren property of the MDI Parent form seemed like an elegant way to go. However, after further investigation it looked like i’d need code some supporting functions for the predicate. What I went with in the end was this:

 Dim formName As String = ""     ' Enter form name here
 For Each f As Form In Application.OpenForms
   If f.IsMdiChild = True AndAlso f.Name = formName Then
      ' Yes, we have a MDI Child form open with the required name
   End If

Here’s the complete code to open a new form, or activate the existing form (if there is one) :

 Dim formName As String = ""    Enter form name here
 Dim openForm As Form = Nothing
 ' Iterate and check for instance
 For Each f As Form In Application.OpenForms
    If f.IsMdiChild = True AndAlso f.Name = formName Then
       openForm = f
    End If
 openForm = CType(IIf(openForm Is Nothing, New OrderForm(New Guid(formName)), openForm), Form)
 openForm.MdiParent = Me

SAP:Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘SAPbobsCOM.ICompany’

SAP Business One DI API

I kept getting the above error when attempting to generate documents on a thread other than the main thread. Here’s the error message in full:

Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘SAPbobsCOM.ICompany’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{3BA8DAED-5B33-4CE4-A4B8-B4308D86E524}’ failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

Turns out that running the following command on the client machine did the trick:

C:\SAP\SAP Business One DI API\DI API 88>regsvr32 SAPbobsCOM88.dll

What was weird here was that previous calls to the COM object on the main thread work fine. Any subsequent calls on a different thread threw the exception.

Incidentally, I have also spotted this error when using some 3rd party (and SAP – Certified) add-ons. In all cases, the above DLL registration command resolved the issue. Your mileage may vary, however.

For more information on the SAP Business One DI API, check out the following link over at the SBO website:

1 2 3 4 5