Search code examples
c#.netdynamicexpandoobject

Expando dynamic object passing to other class requires Microsoft.CSharp.dll?


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...)


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