Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
462 views
in Technique[技术] by (71.8m points)

.net - How do I use the MS DIA SDK from C#?

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 SDKinclude" "%VSINSTALLDIR%DIA SDKidldia2.idl" /tlb dia2.tlb
tlbimp dia2.tlb
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to convert the IDL to a typelib first:

Something like:

midl /I "%VSINSTALLDIR%DIA SDKinclude" 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...