none
COM calls in a WCF Service Library throwing "System.Runtime.InteropServices.SEHException" RRS feed

  • General discussion

  • This is a really weird problem, and I have been trying to solve this for ages!

    I wrote an Excel 2010 64-bit AddIn in VBA

    Then i created a WCF Service Library

    I added the reference of an already existing c++ DLL (32-bit) in WCF Service(C#)

    The WCF services uses netNamedPipeBinding.  There are multiple services in the WCF Service Library project

    The WCF Service exposes the methods that in turn call the methods of the c++ DLL

    The excel VBA uses the methods of WCF Service

    So basically its like this :

    Excel Addin (64-bit) -> WCF Service ( Compiled in 32 bit) -> c++ DLL (32 bit)

    Suppose the C++ DLL is names "Cplusplus"

    So the WCF Service has methods defined like

    class Class1 : IClass1

    {

    public bool Add()

    {

      Cplusplus.CPlusPlusClass CPP = new Cplusplus.CPlusPlusClass();
      return CPP.add() ;

    }

    }

    The first call works fine. If I make another object in another method of another service and call it via VBA

    class class2 : Iclass2

    {

    public boolAddNew(){

     Cplusplus.CPlusPlusAnotherClass CPP1 = new Cplusplus.CPlusPlusAnotherClass();

    return CPP1.addNew();}

    }

    This throws exception

    An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in System.Windows.Forms.dll

    Additional information: External component has thrown an exception.

    Wednesday, February 13, 2013 5:18 AM

All replies