-1

I created a VS 2010 class library. Marked the assembly for Com Visibility. Signed the assembly with a strong key. Created my class, have my entry point method available.

The library works fine from a test project in C#.

I regasm the class library to gac, via: c:\windows\microsoft.net\framework\v4.0.30319\regasm testdll.dll /tlb: testdll.tlb /codebase

Include the tlb file as a reference in my VB6 project. I find it through resources 'browse' so its there.

When i try to instantiate the class... its empty. the public method that should be available via the public class doesn't show.

Dim objTest as testdll.testclass
set objTest = new testdll.testclass

objTest.testmethod   <---  this 'testmethod' doesn't display in intellisense... nothing does.

In addition i tried calling the 'testdll.testclass' via CreateObject, i get the error "ActiveX component can't create object"

Now i have other projects i've done COM visibility for and i've tried comparing the difference, but i don't see any. I can't understand why it isn't working.

Any clues??? tx very much.

4

1 回答 1

1

Just use an interface... one you define or to use the [ClassInterface(ClassInterfaceType.AutoDual)] there are comments online you can find that indicate not to use autodual, but if you control the complete usage of your library, it seems like an 'ok' way to go.

I tried all sorts of ways to simulate / understand why my one project didn't need an interface to be visible by an vb project, without success. i had originally thought perhaps possible that it was because that project implemented an IDisposable Interface (the ONLY interface used in the C# projects that is com visible) but that didn't turn out to be the reason. Anyway I don't want to waste anyone else's time on this. thanks for the responses.

this link provides ample information on the subject: http://anturcynhyrfus.blogspot.com/2011/03/creating-com-visible-c-component.html

于 2013-04-15T17:52:19.627 回答