0

I have a Silverlight Library project that is linked to from a WPF application (shared .xaml and .cs code).

I am trying to add a class to start powershell runspace and execute some commands. Yet I cannot add the reference to the Silverlight library and I get this error:

cannot add reference : it was not built against Silverlight runtime

What reference should I add to Silverlight library so I can invoke PowerShell cmdlets?

Saher Ahwal
  • 9,015
  • 32
  • 84
  • 152

1 Answers1

0

You can't do that as you've discovered because the PowerShell engine was built against the desktop CLR. You create another C# library to put the PowerShell code into. You could also put the code into a Portable Class library that targets both NET 4.0 and Silverlight 4 and higher. I was able to successfully add a reference to the System.Management.Automation assembly but that's no guarantee it will work.

Keith Hill
  • 194,368
  • 42
  • 353
  • 369