How to get GUID (Assembly attribute) of a C# assembly in c++
I am trying to read GUID attribute of a C#.net assembly from c++ (VC++ 10).
I should mention that, I do开发者_StackOverflow社区n't want to use .net or .net reflection. looking for a pure c++ way.
what is the solution ?
Thanks in advance.
You need to use the Unamanaged Metadata API
and especially the IMetaDataImport::EnumCustomAttributes Method
That's going to be quite a work... Here is a link that gives a good starting point on this (it's C#, but the ideas are exactly the same, and is in fact easier to program in C++): Reading types from assembly
Check out the The .NET File Format MetaSection over at CodeProject.
i understand you don't want to use reflection or .net. You do however want to get the GUID from a C# dll you have, that was built with .NET.
The common way C# developers make their class libraries available to COM-based developers is to use the tlbexp.exe (type library export) tool to export a type library file.
The COM-developer can then use the .tlb file in their COM code.
When the C# developer builds the dll they either put the Guid manually in the AssemblyInfo level (in .NET) or the compiler will generate the Guid automatically when building the dll.
show how the COM client (C++) is built to use the COM server (C#) http://msdn.microsoft.com/en-us/library/aa645738%28v=vs.71%29.aspx
note that in this article refers to another tool regasm.exe which registers the dll and can export the tlb at the same time but it is not necessary to register the dll on your system
as a developer you can just use the tlb file
精彩评论