I created ComVisible .Net (C#) dll which holds service reference. When trying to accessing the dll from external COM client (VBScript) exception is thrown whenever I create the object.
The thrown exception is InvalidOperationException (0x80131509).
After short investigation I noticed it fails on the creation of the service reference object ("new"ing it).
- The service reference object used name in the code below is
ServiceClient
ServiceClient
is private for the C# dll- Trying to create the reference in a constructor also fails
- Removing the "new" keyword from both the class or the constructor makes the code pass,
- The service is up and running
The dll code:
namespace UIIdentifier.Updater
{
[ClassInterface(ClassInterfaceType.AutoDispatch)]
public class Client
{
[ComVisible(false)]
//<<--This throws the exception -->>
private ServiceClient uiSpySrv = new ServiceClient();
[ComVisible(true)]
public string hello()
{
return "hello";
}
}
}
The client code:
Dim oUpdater
Set oUpdater = CreateObject("UIIdentifier.Updater.Client")
MsgBox oUpdater.hello
Any suggestions why this happens?