Using `dynamic` keyword in C# doesn't compile

2019-05-10 21:29发布

I'm trying to compile a piece of C# code that contains the dynamic keyword. (I need this keyword for using ironpython.) However, it doesn't compile, complaining that

error CS1980: Dynamic keyword requires 
`System.Runtime.CompilerServices.DynamicAttribute' to be defined.
Are you missing System.Core.dll assembly reference?

The compiler I'm using is Mono JIT compiler version 2.10.8.1. I don't have System.Runtime.CompilerServices.DynamicAttribute in the list of possible references.

How can I make mono accept the dynamic keyword?

1条回答
虎瘦雄心在
2楼-- · 2019-05-10 22:22

This comment of Hans Passant solved the problem:

You need to enable the C# 4 profile, sounds like you didn't. Google "__enable_profile4=yes"

查看更多
登录 后发表回答