3

I've been following a set of tutorials (like this one) to create a simple COM server object.

Say I've got a simple hello world:

[ComVisible(true)]
[Guid("392930B3-9CD0-4247-8C69-83168D1C8F77")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("nathanr.HellowWorldCom")]
class HelloWorldCom : IHelloWorldCom
{
    public int HelloWorld()
    {
        Console.WriteLine("Hello World!");
        return 1;
    }
}

With just as simple an interface:

[ComVisible(true)]
[Guid("C08205BE-1393-4070-AE57-FA47F0D653C3")]
interface IHelloWorldCom
{
    [DispId(1)]
    int HelloWorld();
}

And of course, can't forget the AssemblyInfo.cs file:

...
[assembly: ComVisible(true)]
[assembly: AssemblyKeyFile("HelloWorldCOM.snk")]
...

The problem is when I build the HelloWorldCom.dll and try to register it, regasm just sticks its tongue out at me:

RegAsm : warning RA00000 : No types were registered.

And just to cover my bases I cracked open Regedit and did a search for the ProgID. It wasn't there, which honestly wasn't a surprise.

Am I missing something obvious?

This whole test project is part of a larger (actually useful) set up which is also failing to register.

1
  • you're missing "public" from the class definition. It's going to be internal by default ;) Commented May 29, 2013 at 19:49

2 Answers 2

8

This will be a very long answer: add public

 public class HelloWorldCom : IHelloWorldCom
Sign up to request clarification or add additional context in comments.

1 Comment

/facepalm. Yes this fixes the problem. In my hurry to strip down my earlier issue with COM I missed the public. I'll mark this as the accepted answer, because, yes it certainly does register. But now I'm back to my earlier issue of not being able to create the client object.
0

There might be couple of issues:

  1. You are selecting an incorrect .net framework. In my case, I was trying to register the dll with 2.0 framework, as opposed to 64 bit 4.0 framework

  2. Your DLL is not publicly exposed.

Hope that resolves your issue.

Cheers

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.