4

I have an .exe assembly with a class like

[Guid("2D9EBA5F-7E4A-418B-B151-4E703AEDF396")]
public interface MyInterface
{
   int MyMethod();
}
[GuidAttribute("D26278EA-A7D0-4580-A48F-353D1E455E50"),
ProgIdAttribute("My_prog"), ComVisible(true), Serializable]
public class MyInterface: MyClass
{
   public int MyMethod()
   {
     return 1;
   }
}

I register it like

regasm 1.exe /tlb 1.tlb

I have two questions:

1) I am opening it with an object explorer, "COM" tab. I can see my assembly, I can see an object there, but I can't see any methods in this class. What's wrong?

2) I am trying to reference it from the second project, Add reference -> COM (VS2010). I get the error:

" A reference to 'assemblyname' could not be added.

The ActiveX type Library 'path\1.tlb' was exported from a .NET assembly and can not added as a reference.

Add a reference to .NET instead "

Yes, I have read this question. But I don't want to make a direct reference to the assembly, I want to access it through COM! What should I do to make the assembly referenceable through COM?

VividD
  • 10,456
  • 6
  • 64
  • 111
AndrewR
  • 592
  • 2
  • 6
  • 20
  • Why is your interface not ComVisible? – Paul-Jan Jan 18 '15 at 08:29
  • @Paul-Jan With ComVisible interface I still can't see methods in class, so it doesn't change anything. – AndrewR Jan 19 '15 at 00:21
  • There are several bizarre typos in the question, hard to assume anything. But no, Visual Studio insists that you always use an normal .NET assembly reference instead of a COM reference for .NET assemblies. Using COM makes no sense. – Hans Passant Aug 29 '15 at 13:07
  • Like Hans says, why is you Interface the same name as the class? I would have thought that causes a compile error. – Jeremy Thompson Aug 29 '15 at 13:18

0 Answers0