无法加载交易PowerShell管理单元:的类型初始“Microsoft.Exchange.Data.Directory.Globals'引发了异常 [英] Cannot load Exchange powershell snap-in: The type initializer for 'Microsoft.Exchange.Data.Directory.Globals' threw an exception

查看:2100
本文介绍了无法加载交易PowerShell管理单元:的类型初始“Microsoft.Exchange.Data.Directory.Globals'引发了异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code,创建一个PowerShell运行空间在装在Exchange 2010管理单元。

I have the following code that creates a PowerShell runspace with the Exchange 2010 snap in loaded.

Dim runspaceConfig = RunspaceConfiguration.Create()

Dim snapInException As PSSnapInException = Nothing
runspaceConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.E2010", snapInException)

Dim runspace = RunspaceFactory.CreateRunspace(runspaceConfig)
runspace.Open()

由于安装Visual Studio 2012,我开始执行,增加了管理单元的运行空间配置线时得到以下错误。

Since installing Visual Studio 2012 I started getting the following error when executing the line that adds the snap-in to the runspace config.

System.Management.Automation.Runspaces.PSSnapInException occurred
  HResult=-2146233087
  Message=Cannot load Windows PowerShell snap-in Microsoft.Exchange.Management.PowerShell.E2010 because of the following error: The type initializer for 'Microsoft.Exchange.Data.Directory.Globals' threw an exception.
  Source=System.Management.Automation
  WasThrownFromThrowStatement=False
  StackTrace:
       at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadCustomPSSnapIn(PSSnapInInfo mshsnapinInfo)
       at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIn(PSSnapInInfo mshsnapinInfo)
       at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.LoadPSSnapIn(PSSnapInInfo mshsnapinInfo, PSSnapInException& warning)
       at System.Management.Automation.Runspaces.RunspaceConfigForSingleShell.DoAddPSSnapIn(String name, PSSnapInException& warning)
       at System.Management.Automation.Runspaces.RunspaceConfiguration.AddPSSnapIn(String name, PSSnapInException& warning)

我已经能够证实n日志以某种方式导致此问题。之前的错误创建PowerShell的运行空间的结果创造一个n日志记录器的组合。

I have been able to confirm that nlog is somehow causing this issue. The combination of creating an nlog logger prior to creating the powershell runspace results in the error.

如果我从我的应用程序的配置中删除n日志配置部分,只需要创建一个空的n日志记录器那么管理单元装载有没有错误。另外,如果我离开了n日志配置present在我的应用程序的配置,但不创造一个n日志记录器管理单元也被成功加载。

If I remove the nlog config section from my app config and just create an empty nlog logger then the snap-in is loaded with no error. Also, If I leave the nlog config present in my app config but don’t create an nlog logger the snap-in is also successfully loaded.

  • 在我试图建立在这两个x64和x86的项目。
  • 我已经重新安装了Exchange管理工具。
  • 我在Exchange环境中尝试另一台计算机上进行测试。

如果任何人都可以提供任何可以帮助我解决这个问题的建议,我将不胜感激。

If anyone can provide any suggestions that may help me solve this problem I will be greatful.

感谢您

推荐答案

在进一步调查之后我想通了,.NET 4.5是一个到位的更新意味着.NET 4.0中被覆盖,并安装在与.NET 4.5替换。我不知道是什么改变了.NET 4.5,导致这一点,但问题得到解决通过卸载.NET 4.5和切换回Visual Studio 2010中希望微软将在不久的将来,一些更新,将解决这个问题,让我使用Visual Studio 2012一次。

After further investigation I figured out that .NET 4.5 is an in place update meaning that .NET 4.0 is overwritten and replace with .NET 4.5 when installed. I don't know what changed in .NET 4.5 that causes this but the issue is resolved by uninstalling .NET 4.5 and switching back to Visual Studio 2010. Hopefully Microsoft will have some update in the near future that will resolve the issue and allow me to use Visual Studio 2012 again.

请参阅下面的文章有关的地方更新的详细信息。 <一href="http://www.devproconnections.com/article/net-framework/net-framework-45-versioning-faces-problems-141160" rel="nofollow">http://www.devproconnections.com/article/net-framework/net-framework-45-versioning-faces-problems-141160

See the following article for more info about the in place update. http://www.devproconnections.com/article/net-framework/net-framework-45-versioning-faces-problems-141160

这篇关于无法加载交易PowerShell管理单元:的类型初始“Microsoft.Exchange.Data.Directory.Globals'引发了异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆