HighTechTalks DotNet Forums  

instantiating IGroupPolicyObject

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss instantiating IGroupPolicyObject in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
paul moore
 
Posts: n/a

Default instantiating IGroupPolicyObject - 09-18-2007 , 09:26 PM






I have
[ComImport, Guid("EA502723-A23D-11d1-A7D3-0000F87571E3"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]
interface IGroupPolicyObject
{
.....
}

and
[ComImport, Guid("EA502722-A23D-11d1-A7D3-0000F87571E3")]
class GroupPolicyObject
{
}


I then do


GroupPolicyObject gpo = new GroupPolicyObject();
System.Console.WriteLine("waiting..");
System.Console.Read();
IGroupPolicyObject igpo = (IGroupPolicyObject)gpo;
System.Console.WriteLine("ok");

The cast fails with invlaid cast saying that the object doesnt support the
requested interface (E_NOINTERFACE)

I did run this under windbg and see that
gpedit!CGroupPolicyObject::QueryInterface is called with the IID of
IGroupPolicyObject and it returns OK, but something else is not happy

Doing C++ code
HRESULT hr = CoCreateInstance(CLSID_GroupPolicyObject, NULL,
CLSCTX_ALL, IID_IGroupPolicyObject, (LPVOID*)&p);

works fine, but i want c# (this is 2007 after all)
XP sp2, vs2005

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.