Hi,
I want to instantiate the Shell32.Shell object in Windows 8. I have created a small console project in VS 2012, added reference to Microsoft Shell Controls and Automation. When running the following code
namespace Shell32Test { class Program { static void Main(string[] args) { object shell = new Shell32.Shell(); } } }
The invalid cast exception occurs.
Details of the exception:
System.InvalidCastException was unhandled
HResult=-2147467262
Message=Unable to cast COM object of type 'System.__ComObject' to interface type 'Shell32.Shell'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{286E6F1B-7113-4355-9562-96B7E9D64C54}' failed due
to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Source=Shell32Test
StackTrace:
at Shell32Test.Program.Main(String[] args) in c:\Users\christ.ADLIB\Documents\Visual Studio 11\Projects\Shell32Test\Shell32Test\Program.cs:line 8
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Any ideas how to solve this issue?
Thanks,
C.