-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.

user1161137
  • 1,067
  • 1
  • 11
  • 31
  • Did you regsvr32 the .tlb? I don't get intellisense, either, but I can still use the type. – qxn Apr 12 '13 at 15:14
  • hmmm... do i need to add an interface? i didn't do that in my other projects, and it works... i'm reading another article that says something about that. – user1161137 Apr 12 '13 at 15:17
  • you can't regsvr32 a tlb... isn't that what regasm is doing? – user1161137 Apr 12 '13 at 15:19
  • 1
    Post code. Just the interface and class declarations and their attributes, not the method bodies. – Hans Passant Apr 12 '13 at 16:11
  • adding an interface OR using just [ClassInterface(ClassInterfaceType.AutoDual)] as an attribute to the class seems to work, but this doesn't really resolve my original question. I didn't need to do this for another project i'm actively working on. it was ONLY the comvisible attribute turned on in the project properties, and all methods are visible. Just seems very mysterious. – user1161137 Apr 12 '13 at 16:28
  • what i'm getting at with this, maybe it will get an answer, is that, has newer versions of the framework improved on the ease of making things comvisible that the interface isn't needed any more in lieu of something else? which would some how explain why in one project these attributes were not necessary? although both projects we are talking about here have been created in VS 2010 against framework v4.0. – user1161137 Apr 12 '13 at 16:49

1 Answers1

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

user1161137
  • 1,067
  • 1
  • 11
  • 31