Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Error loading system MshSnapIns exception from C# dll

Reply
 
Old 05-24-2006   #1 (permalink)
Varun Bansal


 
 

Error loading system MshSnapIns exception from C# dll

Hi All,

I've written a C# dll - a wrapper around Exchange cmdlets. I'm calling it
from unmanaged C++ code by COM callable wrapper around my C# dll. The call
to CoCreateInstance( ) returns S_OK with the same error "Error loading
system MshSnapins" but when my C# dll's Initialize( ) function is executed
from my C++ client, I get this exception from the dll. (It works perfectly
fine if the same code runs in an EXE)

System.Management.Automation.Runspaces.MshSnapInException: Error loading
system MshSnapIns. ---> System.Management.Automation.MshArgumentException:
Unable to access Monad registry information.
at System.Management.Automation.MshSnapInReader.GetMonadRootKey()
at System.Management.Automation.MshSnapInReader.GetMshEngineKey(String
mshVersion)
at System.Management.Automation.MshSnapInReader.ReadEngineMshSnapIns()
at
System.Management.Automation.Runspaces.MshConsoleInfo.CreateDefaultConfiguration()
--- End of inner exception stack trace ---
at
System.Management.Automation.Runspaces.MshConsoleInfo.CreateDefaultConfiguration()
at
System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration()
at System.Management.Automation.Runspaces.RunspaceConfiguration.Create()
at
Microsoft.Exchange.Configuration.MonadDataProvider.MonadRunspaceConfiguration.Create()
at MonadWrapper.MonadCmdlets.Initialize()

My Initialize function in C# dll looks like this:

public int Initialize()
{
try
{
AppDomain.CurrentDomain.AssemblyResolve += new
ResolveEventHandler(AssemblyResolver);
rc = MonadRunspaceConfiguration.Create();
r = RunspaceFactory.CreateRunspace(rc);
r.Open();
ri = new RunspaceInvoke(r);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return -1;
}
}


Thanks,
Varun




My System SpecsSystem Spec
Old 05-24-2006   #2 (permalink)
DBMwS


 
 

RE: Error loading system MshSnapIns exception from C# dll

It seems as thought this is a problem with MSH.
Would you try to upgrade to Powershell RC1 updates and then try it out ?
You never know if a problem is fixed or not in recent version of PowerShell.

By the way, how are these variables, "rc, r, ri" declared in your class?

"Varun Bansal" wrote:

> Hi All,
>
> I've written a C# dll - a wrapper around Exchange cmdlets. I'm calling it
> from unmanaged C++ code by COM callable wrapper around my C# dll. The call
> to CoCreateInstance( ) returns S_OK with the same error "Error loading
> system MshSnapins" but when my C# dll's Initialize( ) function is executed
> from my C++ client, I get this exception from the dll. (It works perfectly
> fine if the same code runs in an EXE)
>
> System.Management.Automation.Runspaces.MshSnapInException: Error loading
> system MshSnapIns. ---> System.Management.Automation.MshArgumentException:
> Unable to access Monad registry information.
> at System.Management.Automation.MshSnapInReader.GetMonadRootKey()
> at System.Management.Automation.MshSnapInReader.GetMshEngineKey(String
> mshVersion)
> at System.Management.Automation.MshSnapInReader.ReadEngineMshSnapIns()
> at
> System.Management.Automation.Runspaces.MshConsoleInfo.CreateDefaultConfiguration()
> --- End of inner exception stack trace ---
> at
> System.Management.Automation.Runspaces.MshConsoleInfo.CreateDefaultConfiguration()
> at
> System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration()
> at System.Management.Automation.Runspaces.RunspaceConfiguration.Create()
> at
> Microsoft.Exchange.Configuration.MonadDataProvider.MonadRunspaceConfiguration.Create()
> at MonadWrapper.MonadCmdlets.Initialize()
>
> My Initialize function in C# dll looks like this:
>
> public int Initialize()
> {
> try
> {
> AppDomain.CurrentDomain.AssemblyResolve += new
> ResolveEventHandler(AssemblyResolver);
> rc = MonadRunspaceConfiguration.Create();
> r = RunspaceFactory.CreateRunspace(rc);
> r.Open();
> ri = new RunspaceInvoke(r);
> }
> catch (Exception ex)
> {
> Console.WriteLine(ex.ToString());
> return -1;
> }
> }
>
>
> Thanks,
> Varun
>
>
>
>

My System SpecsSystem Spec
Old 05-25-2006   #3 (permalink)
Vivek Sharma [MSFT]


 
 

Re: Error loading system MshSnapIns exception from C# dll

The error seems pretty specifc to MSH engine, and I haven't seen this before
at least on the Exchange side so I'll let the PS devs comment on this one.

"DBMwS" <DBMwS@discussions.microsoft.com> wrote in message
news:59B8281C-E4F6-4652-ACBD-C3736C077A33@microsoft.com...
> It seems as thought this is a problem with MSH.
> Would you try to upgrade to Powershell RC1 updates and then try it out ?
> You never know if a problem is fixed or not in recent version of
> PowerShell.
>
> By the way, how are these variables, "rc, r, ri" declared in your class?
>
> "Varun Bansal" wrote:
>
>> Hi All,
>>
>> I've written a C# dll - a wrapper around Exchange cmdlets. I'm calling it
>> from unmanaged C++ code by COM callable wrapper around my C# dll. The
>> call
>> to CoCreateInstance( ) returns S_OK with the same error "Error loading
>> system MshSnapins" but when my C# dll's Initialize( ) function is
>> executed
>> from my C++ client, I get this exception from the dll. (It works
>> perfectly
>> fine if the same code runs in an EXE)
>>
>> System.Management.Automation.Runspaces.MshSnapInException: Error loading
>> system MshSnapIns. --->
>> System.Management.Automation.MshArgumentException:
>> Unable to access Monad registry information.
>> at System.Management.Automation.MshSnapInReader.GetMonadRootKey()
>> at System.Management.Automation.MshSnapInReader.GetMshEngineKey(String
>> mshVersion)
>> at System.Management.Automation.MshSnapInReader.ReadEngineMshSnapIns()
>> at
>> System.Management.Automation.Runspaces.MshConsoleInfo.CreateDefaultConfiguration()
>> --- End of inner exception stack trace ---
>> at
>> System.Management.Automation.Runspaces.MshConsoleInfo.CreateDefaultConfiguration()
>> at
>> System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration()
>> at
>> System.Management.Automation.Runspaces.RunspaceConfiguration.Create()
>> at
>> Microsoft.Exchange.Configuration.MonadDataProvider.MonadRunspaceConfiguration.Create()
>> at MonadWrapper.MonadCmdlets.Initialize()
>>
>> My Initialize function in C# dll looks like this:
>>
>> public int Initialize()
>> {
>> try
>> {
>> AppDomain.CurrentDomain.AssemblyResolve += new
>> ResolveEventHandler(AssemblyResolver);
>> rc = MonadRunspaceConfiguration.Create();
>> r = RunspaceFactory.CreateRunspace(rc);
>> r.Open();
>> ri = new RunspaceInvoke(r);
>> }
>> catch (Exception ex)
>> {
>> Console.WriteLine(ex.ToString());
>> return -1;
>> }
>> }
>>
>>
>> Thanks,
>> Varun
>>
>>
>>
>>



My System SpecsSystem Spec
Old 05-26-2006   #4 (permalink)
Varun Bansal


 
 

Re: Error loading system MshSnapIns exception from C# dll

Hi Vivek,

I tried upgrading the powershell to RC1 but current build of Exchange
(version 08.00.0556.008) doesnt recognize it and it wants the older version
of Microsoft command shell so I have to uninstall the RC1 and install the
older version and the problem persists. btw, can you suggest me the exchange
cluster cmdlets which can give me information and status about the cluster
nodes?

Thanks,
Varun

"Vivek Sharma [MSFT]" <viveksha@online.microsoft.com> wrote in message
news:eAK%23nk8fGHA.4004@TK2MSFTNGP04.phx.gbl...
> The error seems pretty specifc to MSH engine, and I haven't seen this
> before at least on the Exchange side so I'll let the PS devs comment on
> this one.
>
> "DBMwS" <DBMwS@discussions.microsoft.com> wrote in message
> news:59B8281C-E4F6-4652-ACBD-C3736C077A33@microsoft.com...
>> It seems as thought this is a problem with MSH.
>> Would you try to upgrade to Powershell RC1 updates and then try it out ?
>> You never know if a problem is fixed or not in recent version of
>> PowerShell.
>>
>> By the way, how are these variables, "rc, r, ri" declared in your class?
>>
>> "Varun Bansal" wrote:
>>
>>> Hi All,
>>>
>>> I've written a C# dll - a wrapper around Exchange cmdlets. I'm calling
>>> it
>>> from unmanaged C++ code by COM callable wrapper around my C# dll. The
>>> call
>>> to CoCreateInstance( ) returns S_OK with the same error "Error loading
>>> system MshSnapins" but when my C# dll's Initialize( ) function is
>>> executed
>>> from my C++ client, I get this exception from the dll. (It works
>>> perfectly
>>> fine if the same code runs in an EXE)
>>>
>>> System.Management.Automation.Runspaces.MshSnapInException: Error loading
>>> system MshSnapIns. --->
>>> System.Management.Automation.MshArgumentException:
>>> Unable to access Monad registry information.
>>> at System.Management.Automation.MshSnapInReader.GetMonadRootKey()
>>> at
>>> System.Management.Automation.MshSnapInReader.GetMshEngineKey(String
>>> mshVersion)
>>> at
>>> System.Management.Automation.MshSnapInReader.ReadEngineMshSnapIns()
>>> at
>>> System.Management.Automation.Runspaces.MshConsoleInfo.CreateDefaultConfiguration()
>>> --- End of inner exception stack trace ---
>>> at
>>> System.Management.Automation.Runspaces.MshConsoleInfo.CreateDefaultConfiguration()
>>> at
>>> System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration()
>>> at
>>> System.Management.Automation.Runspaces.RunspaceConfiguration.Create()
>>> at
>>> Microsoft.Exchange.Configuration.MonadDataProvider.MonadRunspaceConfiguration.Create()
>>> at MonadWrapper.MonadCmdlets.Initialize()
>>>
>>> My Initialize function in C# dll looks like this:
>>>
>>> public int Initialize()
>>> {
>>> try
>>> {
>>> AppDomain.CurrentDomain.AssemblyResolve += new
>>> ResolveEventHandler(AssemblyResolver);
>>> rc = MonadRunspaceConfiguration.Create();
>>> r = RunspaceFactory.CreateRunspace(rc);
>>> r.Open();
>>> ri = new RunspaceInvoke(r);
>>> }
>>> catch (Exception ex)
>>> {
>>> Console.WriteLine(ex.ToString());
>>> return -1;
>>> }
>>> }
>>>
>>>
>>> Thanks,
>>> Varun
>>>
>>>
>>>
>>>

>
>



My System SpecsSystem Spec
Old 05-26-2006   #5 (permalink)
Abhishek Agrawal [MSFT]


 
 

Re: Error loading system MshSnapIns exception from C# dll

We will look into the issue.

--
Abhishek Agrawal [MSFT]
Windows PowerShell Team
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.


"Varun Bansal" <varun_bits@yahoo.com> wrote in message
news:Oh7ijFyfGHA.5088@TK2MSFTNGP02.phx.gbl...
> Hi All,
>
> I've written a C# dll - a wrapper around Exchange cmdlets. I'm calling it
> from unmanaged C++ code by COM callable wrapper around my C# dll. The call
> to CoCreateInstance( ) returns S_OK with the same error "Error loading
> system MshSnapins" but when my C# dll's Initialize( ) function is executed
> from my C++ client, I get this exception from the dll. (It works perfectly
> fine if the same code runs in an EXE)
>
> System.Management.Automation.Runspaces.MshSnapInException: Error loading
> system MshSnapIns. ---> System.Management.Automation.MshArgumentException:
> Unable to access Monad registry information.
> at System.Management.Automation.MshSnapInReader.GetMonadRootKey()
> at System.Management.Automation.MshSnapInReader.GetMshEngineKey(String
> mshVersion)
> at System.Management.Automation.MshSnapInReader.ReadEngineMshSnapIns()
> at
> System.Management.Automation.Runspaces.MshConsoleInfo.CreateDefaultConfiguration()
> --- End of inner exception stack trace ---
> at
> System.Management.Automation.Runspaces.MshConsoleInfo.CreateDefaultConfiguration()
> at
> System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.CreateDefaultConfiguration()
> at System.Management.Automation.Runspaces.RunspaceConfiguration.Create()
> at
> Microsoft.Exchange.Configuration.MonadDataProvider.MonadRunspaceConfiguration.Create()
> at MonadWrapper.MonadCmdlets.Initialize()
>
> My Initialize function in C# dll looks like this:
>
> public int Initialize()
> {
> try
> {
> AppDomain.CurrentDomain.AssemblyResolve += new
> ResolveEventHandler(AssemblyResolver);
> rc = MonadRunspaceConfiguration.Create();
> r = RunspaceFactory.CreateRunspace(rc);
> r.Open();
> ri = new RunspaceInvoke(r);
> }
> catch (Exception ex)
> {
> Console.WriteLine(ex.ToString());
> return -1;
> }
> }
>
>
> Thanks,
> Varun
>
>
>



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
error loading operating system on restart General Discussion
Error loading operating system Vista installation & setup
Can't get into Safe Mode/Error loading Operating System Vista General
Vista Install Error: Exception Unknown Software Exception Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46