How do I create an COM visible class in C#?

前端 未结 3 799
南旧
南旧 2020-11-27 10:34

I using Visual Studio 2010 (.NET 4). I need to create a COM object (in C#) and have no idea how to get started (what type of project to use,etc.)

3条回答
  •  Happy的楠姐
    2020-11-27 11:12

    You could use a class library project. Declare a type with methods that will be exposed as a COM object.

    Make sure that the assembly has been made COM-visible:

    alt text

    And finally register it using regasm.exe:

    regasm.exe /codebase mylib.dll
    

    Now the assembly is exposed as a COM object and the type you declared can be consumed by any client that supports COM.

提交回复
热议问题