Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The way to do what you're trying to do is to translate the IDL definitions into C# interfaces, then implement those interfaces as C# classes. You apply the appropriate attributes (mostly <a href="https://www.google.com/search?sourceid=chrome&amp;ie=UTF-8&amp;q=comvisibleattribute" rel="nofollow">ComVisible</a>, <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.classinterfaceattribute.aspx" rel="nofollow">ClassInterface</a>, and <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.progidattribute.aspx" rel="nofollow">ProgId</a>) to the classes you want to expose to COM, and use the <code>regasm</code> tool to register your assembly as a COM server.</p> <p>Translating IDL into C# is actually not that complex; for the most part it maps pretty directly from IDL keywords to C# keywords and/or <code>MarshalAs</code> attributes. I have a series of blog posts on how to do COM interop w/out <code>tlbimp</code>, including one on <a href="http://blog.kutulu.org/2011/12/com-interop-part-4-look-at-idl.html" rel="nofollow">how to read IDL</a>. I don't know of any tools, specifically, that do a good job of this, but if its part of the Windows SDK you should always check pinvoke.net first in case someone else did it for you.</p> <p>As far as your other options, 3 and 4 both amount to about the same thing. You cannot call managed code directly from unmanaged code unless it's done via COM Interop or a mixed-mode C++ library. In the first case, you'd still have to solve all of the problems of getting your C# assembly registered with COM for your C dll to call, so you may as well skip the middle-man. For the second, you are basically doing manually the same things that the runtime's interop code does for you, and using a language you're less familiar with to boot, which seems like a net loss to me.</p> <p>Be aware, though, that loading .NET assemblies into an unmanaged context isn't always possible; for example, managed shell extensions are explicitly not support in Windows 2008. I don't know if the TSSBX interface will allow you to load managed assemblies as COM objects or not, so you'll have to be aware of that possibility. If you can't, then none of your options are going to work, and you'll have to avoid using the .NET Framework at all and use some other database access technology and write the entire project in unmanaged C++.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload