[SIZE=2][FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#800000]"E5CB7A31-7512-11d2-89CE-0080C792E5D8"[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New])][/FONT]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]ComImport[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]][/FONT]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]InterfaceType[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#008080]ComInterfaceType[/COLOR][/SIZE][SIZE=2].InterfaceIsIUnknown)]
[/SIZE][/FONT][SIZE=2][COLOR=#0000ff][FONT=Courier New]public [/FONT][/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]interface [/COLOR][/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenser
[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]{[/FONT]
[/SIZE][SIZE=2][COLOR=#008000][FONT=Courier New]//[MethodImpl(MethodImplOptions.Unmanaged)][/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080] HRESULT[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] DefineScope ([/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] rclsid, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]uint[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] dwCreateFlags, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] riid, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Out[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] ppIUnk);[/FONT]
[/SIZE][SIZE=2][COLOR=#008000][FONT=Courier New]//[MethodImpl(MethodImplOptions.Unmanaged)][/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080] HRESULT[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] OpenScope ([/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] szScope, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]uint[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] dwOpenFlags, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] riid, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Out[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] ppIUnk[/FONT]
[FONT=Courier New] );[/FONT]
[/SIZE][SIZE=2][COLOR=#008000][FONT=Courier New]//[MethodImpl(MethodImplOptions.Unmanaged)][/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080] HRESULT[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] OpenScopeOnMemory ([/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] pData, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]ulong[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] cbData, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]uint[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] dwOpenFlags, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] riid, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Out[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] ppIUnk[/FONT]
[FONT=Courier New] );[/FONT]
[FONT=Courier New]}[/FONT]
[/SIZE]
COM - интерфейсы
Подзабыл, товарищи, как получить по известному CLSID указатель на COM-интерфейс и потом вызывать его методы (аналог CoCreateInstance из Win32). Вот не помню и всё....
А ты уверен что такой аналог точно есть, я такого точно не знаю, только RCW... Я тут подумал, но так и не понял зачем оно тебе может вообще понадобиться?
Мне нужно заюзать CLI Unmanaged API для получения метаданных (т.к. managed-аналог Reflection не даёт то что мне надо). Вот в Cor.h описаны интерфейсы IMetaDataDispanser и его CLSID. Написал managed-аналог, пометил соотв. атрибутами COMImportAttribute и GuidAttribute, а вот как теперь получить экземпляр??? Смотрел методы в System.Runtime.InteropServices.Marshal классе, но вот как-то они не подходят. В Win32 всё проще, там CoCreateInstance вызвал, получил интерфейс а потом через QueryInterface запрашиваю другие интерфейсы. Вот функция QueryInterface в классе Marshal есть.
Чесно говоря не занимался такими вещами да и думаю тебе не особо полезны мои ответы, но вот я всё-равно посмотрел MSDN и пробежался по статье из Knowledge Base KB307713 (думаю ты сам её прочёл). Я особо не читал но как-то получаетсться что создавать объект всё-равно приходиться вызовом CoCreateInstance(), так что похлже такого аналога и вправду нет.
Разбадяжил вот такой код:
Написал интерфейс на C#:
Код:
Теперь создаю экземпляр ко-класса:
Код:
[SIZE=2][COLOR=#008080][FONT=Courier New]Type[/FONT][/COLOR][/SIZE][FONT=Courier New][SIZE=2] mdDispenserType = [/SIZE][SIZE=2][COLOR=#008080]Type[/COLOR][/SIZE][SIZE=2].GetTypeFromCLSID([/SIZE][SIZE=2][COLOR=#0000ff]new [/COLOR][/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#800000]"E5CB7A31-7512-11d2-89CE-0080C792E5D8"[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]));[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]IMetaDataDispenser[/COLOR][/SIZE][SIZE=2] mdDispenser = ([/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenser[/COLOR][/SIZE][SIZE=2])[/SIZE][SIZE=2][COLOR=#008080]Activator[/COLOR][/SIZE][SIZE=2].CreateInstance(mdDispenserType);
[/SIZE][/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]IMetaDataDispenser[/COLOR][/SIZE][SIZE=2] mdDispenser = ([/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenser[/COLOR][/SIZE][SIZE=2])[/SIZE][SIZE=2][COLOR=#008080]Activator[/COLOR][/SIZE][SIZE=2].CreateInstance(mdDispenserType);
[/SIZE][/FONT]
И получаю эксепшн:
Unable to cast COM object of type 'System.__ComObject' to interface type 'IMetaDataDispenser'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{E5CB7A31-7512-11D2-89CE-0080C792E5D8}' failed due to the following error: Интерфейс не поддерживается (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Я в истерике!!
Код:
[SIZE=2][COLOR=#008080][FONT=Courier New]Type[/FONT][/COLOR][/SIZE][FONT=Courier New][SIZE=2] mdDispenserType = [/SIZE][SIZE=2][COLOR=#008080]Type[/COLOR][/SIZE][SIZE=2].GetTypeFromCLSID([/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#800000]"E5CB7A31-7512-11d2-89CE-0080C792E5D8"[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]));[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][SIZE=2] mdDispenser = [/SIZE][SIZE=2][COLOR=#008080]Activator[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New].CreateInstance(mdDispenserType);[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][SIZE=2] mdDispenserPtr = System.Runtime.InteropServices.[/SIZE][SIZE=2][COLOR=#008080]Marshal[/COLOR][/SIZE][SIZE=2].GetIUnknownForObject(mdDispenser);
[/SIZE][/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][SIZE=2] mdDispenser = [/SIZE][SIZE=2][COLOR=#008080]Activator[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New].CreateInstance(mdDispenserType);[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][SIZE=2] mdDispenserPtr = System.Runtime.InteropServices.[/SIZE][SIZE=2][COLOR=#008080]Marshal[/COLOR][/SIZE][SIZE=2].GetIUnknownForObject(mdDispenser);
[/SIZE][/FONT]
Теперь в mdDispenser экземпляр ко-класса а в mdDispenserPtr указатель на его IUnknown интерфейс. Далее пробую заполучить через Marshal.QueryInterface нужный интерфейс с гуидом [SIZE=2][COLOR=#800000]
"{B81FF171-20F3-11d2-8DCC-00A0C9B09C19}" [COLOR=black]а в ответ вам нулевой указатель. ЗЫ[/COLOR]
[/COLOR][/SIZE]
"E5CB7A31-7512-11d2-89CE-0080C792E5D8"
[/COLOR][/SIZE]попросту не поддерживает интерфейс IMetaDataDispenser (писал с CoCreateInstance на C++, получил E_NOINTERFACE). Зато он поддерживает расширенный интерфейс IMetaDataDispenserEx. Создал соответствующие COM-интерфейсы:
Код:
[SIZE=2][COLOR=#0000ff][FONT=Courier New]using [/FONT][/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]HRESULT[/COLOR][/SIZE][SIZE=2] = System.[/SIZE][SIZE=2][COLOR=#008080]Int32[/COLOR][/SIZE][SIZE=2];
[/SIZE][/FONT][SIZE=2]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#008080]CorHelper[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New].IID_IMetaDataDispenser)][/FONT]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]ComImport[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]][/FONT]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]InterfaceType[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#008080]ComInterfaceType[/COLOR][/SIZE][SIZE=2].InterfaceIsIUnknown)]
[/SIZE][/FONT][SIZE=2][COLOR=#0000ff][FONT=Courier New]public [/FONT][/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]interface [/COLOR][/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenser
[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]{[/FONT]
[/SIZE][SIZE=2][COLOR=#008000][FONT=Courier New]//[MethodImpl(MethodImplOptions.Unmanaged)][/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]HRESULT[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] DefineScope ([/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] rclsid, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]uint[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] dwCreateFlags, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] riid, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Out[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] ppIUnk[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]);[/FONT]
[/SIZE][SIZE=2][COLOR=#008000][FONT=Courier New]//[MethodImpl(MethodImplOptions.Unmanaged)][/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]HRESULT[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] OpenScope ([/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] szScope, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]uint[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] dwOpenFlags, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] riid, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Out[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] ppIUnk[/FONT]
[FONT=Courier New]);[/FONT]
[/SIZE][SIZE=2][COLOR=#008000][FONT=Courier New]//[MethodImpl(MethodImplOptions.Unmanaged)][/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]HRESULT[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] OpenScopeOnMemory ([/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] pData, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]ulong[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] cbData, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]uint[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] dwOpenFlags, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] riid, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Out[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] ppIUnk[/FONT]
[FONT=Courier New]);[/FONT]
[FONT=Courier New]}[/FONT]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]ComImport[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]][/FONT]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#008080]CorHelper[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New].IID_IMetaDataDispenserEx)][/FONT]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]InterfaceType[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#008080]ComInterfaceType[/COLOR][/SIZE][SIZE=2].InterfaceIsIUnknown)]
[/SIZE][/FONT][SIZE=2][COLOR=#0000ff][FONT=Courier New]public [/FONT][/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]interface [/COLOR][/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenserEx[/COLOR][/SIZE][SIZE=2] : [/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenser
[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]{[/FONT]
[/SIZE][SIZE=2][COLOR=#008000][FONT=Courier New]//[MethodImpl(MethodImplOptions.Unmanaged)][/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]HRESULT[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] GetOption([/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] optionId,[/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Out[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][SIZE=2] pvalue [/SIZE][SIZE=2][COLOR=#008000]//VARIANT
[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]);[/FONT]
[/SIZE][SIZE=2][COLOR=#008000][FONT=Courier New]//[MethodImpl(MethodImplOptions.Unmanaged)][/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]HRESULT[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] SetOption ([/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] optionId, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] pvalue[/FONT]
[FONT=Courier New]);[/FONT]
[FONT=Courier New]}[/FONT]
[/SIZE]
[/SIZE][/FONT][SIZE=2]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#008080]CorHelper[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New].IID_IMetaDataDispenser)][/FONT]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]ComImport[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]][/FONT]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]InterfaceType[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#008080]ComInterfaceType[/COLOR][/SIZE][SIZE=2].InterfaceIsIUnknown)]
[/SIZE][/FONT][SIZE=2][COLOR=#0000ff][FONT=Courier New]public [/FONT][/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]interface [/COLOR][/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenser
[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]{[/FONT]
[/SIZE][SIZE=2][COLOR=#008000][FONT=Courier New]//[MethodImpl(MethodImplOptions.Unmanaged)][/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]HRESULT[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] DefineScope ([/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] rclsid, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]uint[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] dwCreateFlags, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] riid, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Out[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] ppIUnk[/FONT][/SIZE]
[SIZE=2][FONT=Courier New]);[/FONT]
[/SIZE][SIZE=2][COLOR=#008000][FONT=Courier New]//[MethodImpl(MethodImplOptions.Unmanaged)][/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]HRESULT[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] OpenScope ([/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] szScope, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]uint[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] dwOpenFlags, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] riid, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Out[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] ppIUnk[/FONT]
[FONT=Courier New]);[/FONT]
[/SIZE][SIZE=2][COLOR=#008000][FONT=Courier New]//[MethodImpl(MethodImplOptions.Unmanaged)][/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]HRESULT[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] OpenScopeOnMemory ([/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] pData, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]ulong[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] cbData, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]uint[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] dwOpenFlags, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] riid, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Out[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]IntPtr[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] ppIUnk[/FONT]
[FONT=Courier New]);[/FONT]
[FONT=Courier New]}[/FONT]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]ComImport[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]][/FONT]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#008080]CorHelper[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New].IID_IMetaDataDispenserEx)][/FONT]
[FONT=Courier New][[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]InterfaceType[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#008080]ComInterfaceType[/COLOR][/SIZE][SIZE=2].InterfaceIsIUnknown)]
[/SIZE][/FONT][SIZE=2][COLOR=#0000ff][FONT=Courier New]public [/FONT][/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]interface [/COLOR][/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenserEx[/COLOR][/SIZE][SIZE=2] : [/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenser
[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]{[/FONT]
[/SIZE][SIZE=2][COLOR=#008000][FONT=Courier New]//[MethodImpl(MethodImplOptions.Unmanaged)][/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]HRESULT[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] GetOption([/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] optionId,[/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]Out[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][SIZE=2] pvalue [/SIZE][SIZE=2][COLOR=#008000]//VARIANT
[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]);[/FONT]
[/SIZE][SIZE=2][COLOR=#008000][FONT=Courier New]//[MethodImpl(MethodImplOptions.Unmanaged)][/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]HRESULT[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] SetOption ([/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] optionId, [/FONT]
[FONT=Courier New] [[/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080]In[/COLOR][/SIZE][SIZE=2]] [/SIZE][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] pvalue[/FONT]
[FONT=Courier New]);[/FONT]
[FONT=Courier New]}[/FONT]
[/SIZE]
Код:
[SIZE=2][COLOR=#0000ff][FONT=Courier New]public [/FONT][/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]static [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]class [/COLOR][/SIZE][SIZE=2][COLOR=#008080]CorHelper
[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]{[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]const [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] CLSID_CorMetaDataDispenser = [/SIZE][SIZE=2][COLOR=#800000]"E5CB7A31-7512-11d2-89CE-0080C792E5D8"[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New];[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]const [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] IID_IMetaDataDispenser = [/SIZE][SIZE=2][COLOR=#800000]"B81FF171-20F3-11d2-8DCC-00A0C9B09C19"[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New];[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]const [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] IID_IMetaDataDispenserEx = [/SIZE][SIZE=2][COLOR=#800000]"31BCFCE2-DAFB-11D2-9F81-00C04F79A0A3"[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New];[/FONT][/SIZE]
[SIZE=2]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]static [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][SIZE=2] CreateCoClass([/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] coClassGuid)[/FONT]
[FONT=Courier New]{[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080] Type[/COLOR][/SIZE][SIZE=2] coClass = [/SIZE][SIZE=2][COLOR=#008080]Type[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New].GetTypeFromCLSID(coClassGuid);[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] return[/COLOR][/SIZE][SIZE=2][COLOR=#008080]Activator[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New].CreateInstance(coClass);[/FONT]
[FONT=Courier New]}[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]static [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] CreateCorMetaDataDispenser()[/FONT]
[FONT=Courier New]{[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] return[/COLOR][/SIZE][SIZE=2] CreateCoClass([/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New](CLSID_CorMetaDataDispenser));[/FONT]
[FONT=Courier New]}[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]static [/COLOR][/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenserEx[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] CreateMetaDataDispenserEx()[/FONT]
[FONT=Courier New]{[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] return[/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenserEx[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New])CreateCorMetaDataDispenser();[/FONT]
[FONT=Courier New]}[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]static [/COLOR][/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][SIZE=2] GetInterfaceID([/SIZE][SIZE=2][COLOR=#008080]Type[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] iface)[/FONT]
[FONT=Courier New]{[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] if[/COLOR][/SIZE][SIZE=2] (iface.Equals([/SIZE][SIZE=2][COLOR=#0000ff]typeof[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenser[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New])))[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] return[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] IID_IMetaDataDispenser;[/FONT]
[/SIZE][SIZE=2][COLOR=#0000ff][FONT=Courier New] else[/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] if[/COLOR][/SIZE][SIZE=2] (iface.Equals([/SIZE][SIZE=2][COLOR=#0000ff]typeof[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenserEx[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New])))[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] return[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] IID_IMetaDataDispenserEx;[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] return [/COLOR][/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New].Empty;[/FONT]
[FONT=Courier New]}[/FONT]
[FONT=Courier New]}[/FONT]
[/SIZE]
[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New]{[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]const [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] CLSID_CorMetaDataDispenser = [/SIZE][SIZE=2][COLOR=#800000]"E5CB7A31-7512-11d2-89CE-0080C792E5D8"[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New];[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]const [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] IID_IMetaDataDispenser = [/SIZE][SIZE=2][COLOR=#800000]"B81FF171-20F3-11d2-8DCC-00A0C9B09C19"[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New];[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]const [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] IID_IMetaDataDispenserEx = [/SIZE][SIZE=2][COLOR=#800000]"31BCFCE2-DAFB-11D2-9F81-00C04F79A0A3"[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New];[/FONT][/SIZE]
[SIZE=2]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]static [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][SIZE=2] CreateCoClass([/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] coClassGuid)[/FONT]
[FONT=Courier New]{[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#008080] Type[/COLOR][/SIZE][SIZE=2] coClass = [/SIZE][SIZE=2][COLOR=#008080]Type[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New].GetTypeFromCLSID(coClassGuid);[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] return[/COLOR][/SIZE][SIZE=2][COLOR=#008080]Activator[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New].CreateInstance(coClass);[/FONT]
[FONT=Courier New]}[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]static [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] CreateCorMetaDataDispenser()[/FONT]
[FONT=Courier New]{[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] return[/COLOR][/SIZE][SIZE=2] CreateCoClass([/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New](CLSID_CorMetaDataDispenser));[/FONT]
[FONT=Courier New]}[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]static [/COLOR][/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenserEx[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] CreateMetaDataDispenserEx()[/FONT]
[FONT=Courier New]{[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] return[/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenserEx[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New])CreateCorMetaDataDispenser();[/FONT]
[FONT=Courier New]}[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]static [/COLOR][/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][SIZE=2] GetInterfaceID([/SIZE][SIZE=2][COLOR=#008080]Type[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] iface)[/FONT]
[FONT=Courier New]{[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] if[/COLOR][/SIZE][SIZE=2] (iface.Equals([/SIZE][SIZE=2][COLOR=#0000ff]typeof[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenser[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New])))[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] return[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] IID_IMetaDataDispenser;[/FONT]
[/SIZE][SIZE=2][COLOR=#0000ff][FONT=Courier New] else[/FONT]
[/COLOR][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] if[/COLOR][/SIZE][SIZE=2] (iface.Equals([/SIZE][SIZE=2][COLOR=#0000ff]typeof[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#008080]IMetaDataDispenserEx[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New])))[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] return[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New] IID_IMetaDataDispenserEx;[/FONT]
[/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff] return [/COLOR][/SIZE][SIZE=2][COLOR=#008080]Guid[/COLOR][/SIZE][/FONT][SIZE=2][FONT=Courier New].Empty;[/FONT]
[FONT=Courier New]}[/FONT]
[FONT=Courier New]}[/FONT]
[/SIZE]
И вуаля:
Код:
[SIZE=2][COLOR=#008080][FONT=Courier New]IMetaDataDispenserEx[/FONT][/COLOR][/SIZE][FONT=Courier New][SIZE=2] dispenser = [/SIZE][SIZE=2][COLOR=#008080]CorHelper[/COLOR][/SIZE][SIZE=2].CreateMetaDataDispenserEx();
[/SIZE][/FONT]
[/SIZE][/FONT]
Получаю желаемый результат!!!!!!!
Как же я сразу не сказал, в MSDN по этому интерфесу и было написано, что IMetaDataDispenser "oblivious" и используйте IMetaDataDispenserEx.
Всё бы ничего, только не получается что-то правила маршаллинга назначить для функций.