Okay, I'm going crazy. I am trying to make a simple .net assembly visible for use as a COM object, but it does not work. I tried a lot of different applause, but none of them work. So far, the closest I have is the one with the least number of attributes, interfaces, manual registration, etc.
I have vbscript as a test that looks like this:
Dim o o = CreateObject("MyNamespace.MyClass") msgbox o.Test()
My C # code is as follows:
using System; using System.Runtime.InteropServices; namespace MyNamespace { [ProgId("MyNamespace.MyClass")] public class MyClass { public string Test() { return "teststring"; } } }
In my project (VS2008), I selected "Make COM Assembly Visible" - adding an attribute to my AssemblyInfo.cs, and I also checked "Register for COM Interop."
I see that ProgId really does not matter (anyway), if I specify the real namespace + class name, I can, however, override it, which I believe is good.
The problem is that my CreateObject is going well, but the Test () method was not found. In fact, if I take a dll and retrieve tlb and expect to see no methods at all.
The error I am getting is this:
C: \ Inetpub \ Wwwroot \ ASPTest \ testrun.vbs (3, 1) Microsoft VBScript runtime error: The object does not support this property or method: "Test"
I would love any feedback, but just to let you know that I tried. I fiddled with Guid and AttributeGuid in the class, defining COMVisible explicitly in the class, and I also tried NOT to register for COM interaction and instead used regasm / codebase / regfile.
One last note - most of my tests revolved around an unsigned assembly, but tried to pinpoint the error that I tried using a strong name / key, but did nothing.
Can someone help me find the problem please?