Question

I have build a function:

 string removeFile(HttpContext context,HttpRequest r)
 {       
       dynamic d = new ExpandoObject() ;
       d.ItemCommand = r["itemId"].ToString();
       ...
       ...
       int res = new PolicyDal().Admin_Kits_AttachFile(d); //sending here the d.

on the other class/file:

   public int Admin_Kits_AttachFile(dynamic d)
   {
        DbCommand command = _webERPDB.GetStoredProcCommand("Admin_Kits_AttachFile");
        _webERPDB.AddInParameter(command, "@ItemCommand", DbType.String, d.ItemCommand);

The following error occurs:

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

I've referenced after finding the DLL in FILE SYSTEM since it was not in the regular add reference menu.

why is that ? why it wont compile ? why they didnt put the dll in the normal add reference menu ? ( I had to find the dll in the file system...)

Was it helpful?

Solution

This assembly contains the DLR. If you need to use dynamic dispatching in your application it must be referenced. It is added as reference by default when you start a new application in VS 2010 (Console, WinForms, ASP.NET, Class library).

why they didnt put the dll in the normal add reference menu?

Actually they did:

enter image description here

OTHER TIPS

This error always happens when you use some feature about dynamic object. Complier will throw error about missing Microsoft.CSharp.dll and System.Core.dll.

enter image description here

The cause of this problem is all dynamic object need to be dynamically generated class at runtime like the following image.

enter image description here

To solve this problem you just add reference to "Microsoft.CSharp.dll" for allowing runtime to dynamic compile dynamic object like the image below.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top