"One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll?"的解决方法

#事故现场:

  在一个.net 4.0 的项目中使用dynamic,示例代码如下:

1 private static void Main(string[] args)
2 {
3     dynamic obj;
4     obj = new { name = "jack" };
5     Console.WriteLine(obj.name);
6 }

  在读取obj.name时,报错:

One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll?

#解决方法:

  在项目中,添加Microsoft.CSharp.dll的引用;

#参考:

https://stackoverflow.com/questions/11725514/one-or-more-types-required-to-compile-a-dynamic-expression-cannot-be-found-are

——————————————————————————————————————————————————

 

posted @ 2019-05-26 15:21  willingtolove  阅读(579)  评论(0编辑  收藏  举报