tags:

views:

500

answers:

1

I'm trying to use the Microsoft Debug Interface Access SDK from C#. This is installed with Visual Studio, but the docs don't seem to mention how you use this from C#.

I've found example code on interweb but no information on how to link to the DIA SDK. I.e. I can't import it as an assembly. I don't think I have to include it into a managed C++ application and use it as COM (that would be hell).

There is an IDL file, is this the correct way? If so, how?


Edit: The following will create the type library for use as a referenced assembly. Paste into a batch file.

call "%VS80COMNTOOLS%\vsvars32.bat"
midl /I "%VSINSTALLDIR%\DIA SDK\include" "%VSINSTALLDIR%\DIA SDK\idl\dia2.idl" /tlb dia2.tlb
tlbimp dia2.tlb
+3  A: 

You need to convert the IDL to a typelib first:

Something like:

midl /I "%VSINSTALLDIR%\DIA SDK\include" dia2.idl /tlb dia2.tlb
tlbimp dia2.tlb

Then you can import the tlb.

I've never used the DIA SDK this way, so don't know how friendly it would be. You could also consider using it directly from a managed C++ assembly and presenting a managed interface to the functionality you need.

Rob Walker
Thanks. Would that be using the DllImport PInvoke stuff?
Nick
You said you've "never used the DIA SDK this way". If you don't use it that way, how do you use it?
Nick
Once you've run tlbimp on the generated tlb you should get an assembly you can reference from your managed code. The assembly will do the COM interop from you and there is no need to dllimport or PInvoke anything.I've only used it from unmanaged C++
Rob Walker
Great, thanks. I'll paste my batch file in above. I have a DLL now. I did a lot of this quite a while ago and forgot the details.
Nick