2

I'm obviously missing something trivial, but I can't seem to import from System.Dynamic; to wit:

import clr
clr.AddReference('System.Dynamic')

which clearly adds the salient reference:

clr.References[2]
(< System.Dynamic, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a>)

but importing fails

import System.Dynamic

results in:

Traceback (most recent call last):
File "", line 1, in
ImportError: No module named Dynamic

What basic thing am I missing?

1 Answer 1

1

The System.Dynamic assembly in .NET 4.0 actually includes no public surface area. It just has a bunch of internal types which are visible to the C# runtime assembly that are used for COM interop. The decision to make this all internal was made late enough in the product cycle that the assembly still remains.

Likely you want Microsoft.Dynamic instead which contains a superset of the functionality in System.Dynamic. Microsoft.Dynamic is shipped w/ IronPython.

Sign up to request clarification or add additional context in comments.

3 Comments

Exact same behavior with Microsoft.Dynamic.
Well after doing an add ref to Microsoft.Dynamic you won't be able to import a "System.Dynamic" namespace. Instead you'll need to import namespaces defined in that assembly such as Microsoft.Scripting.
One useful way to see what namespaces are available is to do: x = clr.LoadAssemblyByName('Microsoft.Dynamic') dir(x) which will let you inspect the namespaces in an assembly (sorry for the formatting, enter is commiting edits for some reason instead of inserting new lines)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.