Trying to use a COM visible .NET class via other .NET application and get exception:
Message: The object's type must be __ComObject or derived from __ComObject.
Parameter name: o
Stack Trace: at System.Runtime.InteropServices.Marshal.ReleaseComObject(Object o)
The class looks as follows:
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IViewer : IComInteropDefinedInterface
{
}
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
[Guid("[some guid]")]
public class MyViewer : UserControl, IViewer
{
//IViewer implementation
}
I register the component with:
regasm [Assembly Path] /tlb /codebase
The client application, which is also in .NET instantiates successfully the given class, but when he callsMarshal.ReleaseComObject()
it gets the exception described above.
Any idea for solving this problem?
EDIT: Unfortunately I can't provide the client application code for instantiating my object. However I know the client is using the same method to instantiate real COM objects.