[Source: http://geekswithblogs.net/EltonStoneman]

You can actually use this to check for correct deployment of any .NET stack where you want to verify that assemblies and dependencies in the GAC are correctly deployed. Mostly I use it for troubleshooting when BizTalk can’t load maps or schemas.

With PowerShell you can instantiate any .NET object, and if there are any issues in loading the assembly or its dependencies, you’ll see the whole error message, which might otherwise be truncated or buried in a stack trace somewhere.

Firstly load the assembly so PowerShell can locate the type. Use the full name if you’re loading from the GAC, or the basic name if you’ve navigated to a program’s bin directory:

[System.Reflection.Assembly]::Load(‘x.y.z.Integration.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=104fee075643f423’)

Next use Activator to create and unwrap an instance from the assembly and type name. If this fails, it will highlight any issues with missing dependencies:

$map = [System.Activator]::CreateInstance(‘x.y.z.Integration.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=104fee075643f423’, ‘x.y.z.Integration.Maps.x_yService_Getz’).Unwrap()

If you don’t have any error messages, then your object ($map in this example) is ready to use, and you’ve verified the deployment is correct. For BizTalk maps you have the additional benefit that running ToString() (or just entering the object name) will show you the underlying XSLT:

$map

If you get do get errors along the way, they should tell you where the problem is. You can get more detail by querying the PowerShell $error object.