Click to See Complete Forum and Search --> : C Sharp library in native COM dll


SilentSniper
April 8th, 2008, 09:39 PM
Hi,
I have a very basic conceptual doubt.
I am trying to create a legacy InProc component in COM using ATL library.(There is a restriction due to business reasons of not using the C# dll)

I already have an existing C# application which I have created.I want to now create that application as a component so that it can be dynamically loaded in my client.

I am using dot net framework class libraries like System.XMLParser etc... in the application

So when I am trying to create COM component out of this how can I use dot net framework class library function in my legacy COM component.

For Ex
public void addRef(ManifestType type, string fileName)
{
string coll = CollectionString(type);
string item = ElementString(type);
XmlElement node = doc.DocumentElement;
XmlNodeList nl = doc.GetElementsByTagName(coll);
XmlElement elem = doc.CreateElement(item);
nl.Item(nl.Count-1).AppendChild(elem);
XmlText text = doc.CreateTextNode(fileName);
nl.Item(nl.Count-1).LastChild.AppendChild(text);
}
I want to port this function in my ATL COM dll

How would I use the XmlElement and others inside my dll since C++ donot have an inbuilt parser?
Please Help....

Alex F
April 9th, 2008, 04:42 AM
C# class library can be exposed to unmanaged C++ as COM component. In your native C++ client you need to write COM client code to instantiate C# class instance and call its methods. See details here:
http://support.microsoft.com/kb/828736