views:

322

answers:

2

I tried loading PresentationFramework.dll from .net 4.0 beta2 in PowerShell v2.0. But it fails with the following error.

PS C:\Windows\system32> [Reflection.Assembly]::LoadFile("C:\Windows\Microsoft.NET\Framework\v4.0.21006\WPF\PresentationF ramework.dll")

Exception calling "LoadFile" with "1" argument(s): "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. (Exception from HRESULT: 0x8013101B)" At line:1 char:32 + [Reflection.Assembly]::LoadFile <<<< ("C:\Windows\Microsoft.NET\Framework\v4.0.21006\WPF\PresentationFramework.dll") + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException

Any idea how can I load this DLL within PowerShell 2.0?

A: 

You can't load it, PowerShell is using the .NET 2.0 CLR. 4.0 dlls cannot be loaded.

It might be possible to reconfigure PowerShell to run in the newer CLR or host PowerShell in a 4.0 app, but I wouldn't recommend either of those

Sander Rijken
A: 

Similar question is addressed in launch powershell under .NET 4

Oleg Zhylin

related questions