breakpoint
breakpoint

Reputation: 1

Problems with COM object C#

I have to adjust dll to be COM object (one main class in the class library). This dll has reference to other dlls. When i'm using C# attributes for COM and register the dll, i can't work with this class, the registration register a lot of mess in the registry (few public classes in my class library, that i don't want to expose them as com). It drive me crazy this issue, does anyone know whether com interface in C# force changes in the reference dlls (when i'm creating a simple class and interafce it works great, that why i think it is related to the references dlls)? Please help me!!!

Thanks is advance!!!

Upvotes: 0

Views: 127

Answers (1)

Arseny
Arseny

Reputation: 7361

use Attibutes in that assembly. if you don't want public classes be visible as COM interfaces

[ComVisible(false)]

then there are some options how to make it COM-visible one of them: make an interface with attributes

 [ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("new generated GUID")]
public interface ISample
{
 void DoSomthing();
}

then implement this interface

[Guid("new generated GUID")]
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces(typeof(ISample))]
[ProgId("YourModule.YourClass")]
[ComVisible(true)]
public class YourClass :  ISample

Upvotes: 1

Related Questions