Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create and Register a COM Server Object .NET

Tags:

c#

com

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.

like image 761
Nathan R Avatar asked Jan 29 '26 02:01

Nathan R


1 Answers

This will be a very long answer: add public

 public class HelloWorldCom : IHelloWorldCom
like image 71
I4V Avatar answered Jan 30 '26 14:01

I4V



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!