Re: Creating COM server with C#



m.a wrote:
"Marc Gravell" <marc.gravell@xxxxxxxxx> wrote in message news:epvwSkVwIHA.5472@xxxxxxxxxxxxxxxxxxxxxxx
You cannot AFAIK write a native COM server in C#.

What you *can* do is write a "serviced component" (i.e. a COM+ dll that you can host as a COM+ application in "Component Services".

http://msdn.microsoft.com/en-us/library/ty17dz7h.aspx

Alternatively, you can use a COM-server compatible framework to write a shim COM server to the managed (.NET) COM library (dll); for quick'n'dirty jobs I've used VB6 for this; or C++ if you are literate with it (I'm not very...).

Marc


Thanks Marc,
What is the difference between COM and COM+? I want to use my COM in matlab. Can I write COM+?

Regards


It is pretty easy to expose interfaces as COM. You just need to decorate the interface and or its methods with [ComVisible(true)] following is an example interface.
[ComVisible(true)]
public interface ITypeDefinition : IDisposable
{
/// <summary>
/// Get the name of this type
/// </summary>
String TypeName{get;}
}

Once you have the assembly built you can use the regasm tool to register it.

Use help on ComVisible and regasm to find out the details. You might check www.codeproject.com for examples. I find most everything I have questions about has some sort of example there.

Hope that helps.
Leon Lambert
.



Relevant Pages

  • Re: Properties Shared Amongst Objects
    ... The host can query my application for certain ... In that context one usually strives to provide a subsystem interface that reflects the invariants of the DLL subject matter. ... A some point the conversion may become so complex that one wants to deal with it explicitly within the DLL subject matter. ...
    (comp.object)
  • Re: Explicit Linking of DLLs in VB.net
    ... yes this technique will only work on managed assemblys (exe or dll) ... "YourObject" is a form and is limited to the form methods. ... Wel implement propertys, methods, events in your interface and start ... Public Shared Function LoadMeByName(ByVal vstrAssemblyName As String, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Explicit Linking of DLLs in VB.net (attn Michel or any others)
    ... loads the dll and finds a form in the dll. ... Dim extForm As Form = extAssembly.CreateInstance("test.entry", ... Wel implement propertys, methods, events in your interface and start ... Public Shared Function LoadMeByName(ByVal vstrAssemblyName As String, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Problem marshalling interface pointer into local server
    ... It can be applied to the proxy/stub DLL as well. ... Mind you this is not the most efficient way of producing a DLL ... Now that would be correct - an Automation-compatible interface ... I had an issue where I have a in-proc server (server ...
    (microsoft.public.vc.atl)
  • Re: Implements Interface difference in VB IDE and Compiled version, is this a BUG!???
    ... You need to set binary compatibility to the compiled dll. ... > it seams that VB in IDE Runtime mode with ActiveX component doesn't ... > |> TLB file contains interface IWPSpecific, ...
    (microsoft.public.vb.general.discussion)