Why doesn't Add-Type work with the BizTalk 2010 Microsoft.BizTalk.ExplorerOM
assembly?
I can happily work the ExplorerOM
objects if I load the old way via reflection ...
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.BizTalk.ExplorerOM")
But I use the proper way with Add-Type
...
Add-Type -AssemblyName Microsoft.BizTalk.ExplorerOM
I get the cannot add type
error ...
Add-Type : Cannot add type. The assembly 'Microsoft.BizTalk.ExplorerOM' could not be found.
At E:\loadexplorerom.ps1:5 char:1
+ Add-Type -AssemblyName Microsoft.BizTalk.ExplorerOM
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.BizTalk.ExplorerOM:String) [Add-Type], Exception
+ FullyQualifiedErrorId : ASSEMBLY_NOT_FOUND,Microsoft.PowerShell.Commands.AddTypeCommand
I've checked my GAC and the BizTalk 2010 ExplorerOM is in there ...
Microsoft.BizTalk.ExplorerOM, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
PowerShell is very much limited in loading predefined set of assemblies with their partial name.
In your case also it is the same. You have to tell powershell to load that particular assembly for the Biztalk server.
In other words, you have to give the full path of the dll :
Sample:
Add-Type -Path C:\Windows\Microsoft.NET\assembly\GAC_64\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll
Try adding this also:
Add-Type -AssemblyName ('Microsoft.BizTalk.ExplorerOM, Version=3.0.1.0, ' + 'Culture=neutral, PublicKeyToken=31bf3856ad364e35' + 'processorArchitecture=MSIL')