Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8579103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:32:28+00:00 2026-06-11T20:32:28+00:00

I have the following code that creates a PowerShell runspace with the Exchange 2010

  • 0

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()

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)

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.

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.

  • I have tried building the project in both x64 and x86.
  • I have re-installed the exchange management tools.
  • I have tried testing on another machine in the exchange environment.

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

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:32:30+00:00Added an answer on June 11, 2026 at 8:32 pm

    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.

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that creates a serverside object of the xmlhttp class.
I have the following code that creates the meta-description. I'm getting a 0 as
I have the following code that creates a submenu based on current document. The
I have a method that contains the following (Java) code: doSomeThings(); doSomeOtherThings(); doSomeThings() creates
I have the following code, that in my head should create a new row
I have the following code that creates a draggable and droppable element/area. And when
I have created an application that creates notifications, using the following code: // notification
I have following code that creates Linq query. I've never used Linq until today
I have the following C# code that creates a DateTime , enters it into
So I have the following VB.NET code that creates a form field in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.