Trying to use COM visible .NET class through another .NET application and get an exception:
Message: The type of the object must be __ComObject or derived from __ComObject.
Parameter Name: o
Stack Trace: with System.Runtime.InteropServices.Marshal.ReleaseComObject (Object o)
The class is as follows:
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IViewer : IComInteropDefinedInterface
{
}
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
[Guid("[some guid]")]
public class MyViewer : UserControl, IViewer
{
}
I register component with
regasm [Assembly Path] /tlb /codebase
The client application, which is also located in .NET, successfully creates this class, but when it calls Marshal.ReleaseComObject(), it receives the exception described above.
Any idea to solve this problem?
EDIT:
Unfortunately, I cannot provide client application code to instantiate my object. However, I know that the client uses the same method to create real COM objects.