Ah, I see. Guid is simply a custom attribute. The following should do the
trick:

TypeDefinition interfaceTypeDef = ...; // get the TypeDefinition of
_interface
string guid = interfaceTypeDef.CustomAttributes.FirstOrDefault(ca =>
ca.AttributeType == interfaceTypeDef.Module.Import(typeof
(System.Runtime.InteropServices.GuidAttribute))).ConstructorArguments[0].Value.ToString();

Hope that helps.

2011/3/25 Simon zack <[email protected]>

>
> Say a class imports an interface:
>
> [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
> Guid("0000000c-0000-0000-C000-000000000046")]
> public interface _interface{
> ...
> }
>
> I want to get this "0000000c-0000-0000-C000-000000000046"
>
> thanks
>
> On Sat, Mar 26, 2011 at 4:37 AM, Gábor Kozár <[email protected]> wrote:
>
>> I'm not sure what you want. Could you please rephrase your question?
>>
>> Do you need the Guid of the assembly? What "external interface" are you
>> referring to? Can you give us an example?
>>
>> Thanks!
>>
>> 2011/3/25 simonzack <[email protected]>
>>
>>> How do I get the guid or get a pointer to an external interface?
>>> it shows up in reflector, which uses mono cecil, so I think cecil can
>>> do it
>>>
>>> thanks
>>>
>>> --
>>> --
>>> mono-cecil
>>
>>
>>  --
>> --
>> mono-cecil
>
>
> --
> --
> mono-cecil

-- 
--
mono-cecil

Reply via email to