ekolis
ekolis

Reputation: 6786

How do I reference Microsoft.CSharp in a Portable Class Library?

I'm trying to use .NET 4's dynamic type in a Portable Class Library, but I'm having trouble getting all the required references working. I can reference System.Core just fine, but Microsoft.CSharp is giving me some trouble. It seems like I need to add all the different versions of Microsoft.CSharp.dll as references to my project, but Visual Studio is allowing me to add only one; if I add another, I get an error saying that it's already referenced. I can't compile with just one of them, though - if I reference the Windows one, I get:

Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember'

when I try to build the project. And if I reference the Silverlight one, the reference seems to be invalid for some reason - it has a yellow warning icon it in the reference list in Solution Explorer!

So is there any way I can reference both of these DLL's without breaking my project or converting it to a non-portable library?

Thanks!

Upvotes: 2

Views: 1466

Answers (1)

casperOne
casperOne

Reputation: 74530

You cannot create a portable library that utilizes the dynamic keyword in .NET 4.0.

Support for dynamic types in portable libraries was added in .NET 4.5.

In .NET 4.0, you'll have to resort to using Reflection in order to make the calls that you want to make (if you can't upgrade to 4.5).

Upvotes: 3

Related Questions