This is complicated, at least for me, so please bare with me. I'll also preface with I've spent a day searching, to no avail.
Due to company constraints out of my control, I have the following scenario:
A COM library that defines the following interface (no CoClass, just the interface):
[
object,
uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx),
dual,
nonextensible,
helpstring("IService Interface"),
pointer_default(unique)
]
IService : IDispatch
{
HRESULT DoSomething();
}
[
object,
uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx),
dual,
nonextensible,
helpstring("IProvider Interface"),
pointer_default(unique)
]
IServiceProvider : IDispatch
{
HRESULT Init( IDispatch *sink, VARIANT_BOOL * result );
HRESULT GetService( LONG serviceIndicator, IService ** result );
};
[
uuid(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx),
version(1.0),
]
library ServiceLibrary
{
importlib("stdole2.tlb");
interface IService;
interface IServiceProvider;
};
I have a COM (written w/ C++) that implements both interfaces and to provide our application(s) with said service. All is fine, I think.
Now, I'm trying to build a new IProvider and IService in .NET (C#).
I've built (I think correctly) a Primary Interop Assembly for the COM library, and implemented the following C#:
[ComVisible( true )]
[Guid( "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" )]
public interface INewService : IService
{
// adds a couple new properties
}
[ComVisible( true )]
[Guid( "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" )]
public class NewService : INewService
{
// implement interface
}
[ComVisible( true )]
[Guid( "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" )]
public interface INewProvider : IServiceProvider
{
// adds nothing, just implements
}
[ComVisible( true )]
[Guid( "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" )]
public class NewProvider : INewProvider
{
// implement interface
}
When I attempt to slip this into the existing runtime, I am able to create the NewProvider object from COM (C++), and QueryInterface for IServiceProvider, but when I attempt to call a method on the IServiceProvider, a System.ExecutionEngineException is thrown.
The only other thing I can find, is by looking at the .tlh files created by the #import, shows the legacy COM IExistingProvider class correctly shows that it is derived from IServiceProvider, yet the .NET class shows a base of IDispatch. I'm not sure if this a sign, indication, helpful, something else.
Any help would be tremendously appreciated.
Thanks.