Search Unity

Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'

Discussion in 'macOS' started by JanetEscGames, Oct 2, 2018.

  1. JanetEscGames

    JanetEscGames

    Joined:
    May 2, 2018
    Posts:
    5
    When I try and compile C# code using the "dynamic" keyword, I get the error "Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'"

    I'm building using Visual Studio for Mac

    I've googled the error and it seems that you fix it by adding the Microsoft.CSharp.dll, but this will obviously not work on Mac.

    Has anyone encountered this?
     
  2. Alanyeats

    Alanyeats

    Joined:
    Feb 20, 2016
    Posts:
    23
    I've come across the exact same issue in 2018.2, Not found a good solution for it yet.
     
  3. JanetEscGames

    JanetEscGames

    Joined:
    May 2, 2018
    Posts:
    5
    We decided to not use the "dynamic" keyword for now, it doesn't seem to be supported.
     
  4. MirkoSon

    MirkoSon

    Joined:
    Oct 14, 2015
    Posts:
    24
    Actually, you just need to set the Api Compatibility Level to .Net 4.x in your Player Settings, if you need to use the dynamic keyword.
     
  5. ivanngoc

    ivanngoc

    Joined:
    Nov 9, 2018
    Posts:
    9
    JCxYIS likes this.
  6. taynaTinoco

    taynaTinoco

    Joined:
    Jul 31, 2018
    Posts:
    6
    just change the Api Compatibility Level to . NET 4.x and Scripting Backend IL2CPP
     
  7. wechat_os_Qy00shpMJZXLuBQ2aeDR-VtIE

    wechat_os_Qy00shpMJZXLuBQ2aeDR-VtIE

    Joined:
    Mar 4, 2020
    Posts:
    1
    Thank your advice,it's useful!
     
  8. Jessmy

    Jessmy

    Joined:
    Mar 30, 2019
    Posts:
    1
    Thank you!!
     
  9. vamidi16

    vamidi16

    Joined:
    Sep 5, 2013
    Posts:
    4
    Thank you!! I was so confused, because I already added it to unity and it still complained..
     
  10. foote

    foote

    Joined:
    Apr 19, 2013
    Posts:
    1
    thank you!
     
  11. minthiha

    minthiha

    Joined:
    Dec 4, 2013
    Posts:
    9
    Thanks
     
  12. _DS_1

    _DS_1

    Joined:
    Sep 6, 2016
    Posts:
    17
    Can someone help ?
    Unity Version is 2021.2.5f
    Seting either value doesn't solve the problem, I'm too trying to use the dynamic keyword

    upload_2022-1-31_16-41-48.png

    In other versions of Unity I can see the .NET 4.x, but in that is not showing
     
  13. Sergio26Diaz

    Sergio26Diaz

    Joined:
    Apr 25, 2019
    Posts:
    10
    did you by any chance find a solution?
     
  14. RChrispy

    RChrispy

    Joined:
    Dec 18, 2013
    Posts:
    71
    I am using 2021.1 and it works normally I can use dynamic and .Net 4. In the newer versions the name was changed to just .NET Framework but it should work the same.

    PS: Make sure to have installed new C# SDK as well separately.
     
    russisunni likes this.
  15. keltoum1

    keltoum1

    Joined:
    Jun 26, 2022
    Posts:
    1
    Hello, please I'm trying to install 'Microsoft.CSharp' in my power shell but i get this error: (Error adding package 'Microsoft.CSharp' to project ''. The project does not support adding package references through the add package command) I'm using this command: dotnet add package Microsoft.CSharp --version 4.7.0
     
  16. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Hey there! I wanted to follow up with this thread to indicate that the dynamic keyword is not something that we support in Unity. It seems that it did happen to work in earlier versions of Unity. I would recommend avoiding its use if at all possible.
     
    mdimov, Dance_M, monxterz and 2 others like this.
  17. mdimov

    mdimov

    Joined:
    Oct 22, 2017
    Posts:
    2
    @JoshPeterson Thanks for this confirmation. Would you have recommendations for workarounds, given that this is a known incompatibility?
     
  18. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    That is difficult to say, in general. It will depend on your specific use case.
     
  19. Alexzoin

    Alexzoin

    Joined:
    Jan 17, 2019
    Posts:
    2
    Any thoughts on what I may be able to use here?


    Code (CSharp):
    1. public dynamic SendMessage(String messageURI, String messageParams, String authCode = "")
    2.     {
    3.         byte[] result = this.SendMessage(messageURI, HttpUtility.ParseQueryString(messageParams), authCode);
    4.  
    5.         string utfString = Encoding.UTF8.GetString(result, 0, result.Length);
    6.         return JsonConvert.DeserializeObject<dynamic>(utfString);
    7.     }
    8.  
    9.     public byte[] SendMessage(String messageURI, NameValueCollection messageParams, String authCode = "")
    10.     {
    11.         using (WebClient client = new WebClient())
    12.         {
    13.             ServicePointManager.Expect100Continue = true;
    14.             ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
    15.                     | SecurityProtocolType.Tls11
    16.                     | SecurityProtocolType.Tls12
    17.                     | SecurityProtocolType.Ssl3;
    18.  
    19.             client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
    20.             if(!String.IsNullOrEmpty(authCode))
    21.                 client.Headers[HttpRequestHeader.Authorization] = authCode;
    22.  
    23.             byte[] HtmlResult = client.UploadValues(messageURI, messageParams);
    24.  
    25.  
    26.             return HtmlResult;
    27.         }
    28.     }
    Which gets used like:

    Code (CSharp):
    1. var returnData = this.SendMessage(MessageURI, MessageParams, this._authorization);
    2.         if (returnData["status"].Equals(1) && returnData["message"].Equals("success"))
    3.         {
    4.             long.TryParse(returnData["data"]["id"].ToString(), out returnId);
    5.         }
    6.         return returnId;
     
  20. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I'm not too sure. What is the API for JsonConvert.DeserializeObject? Can its type parameter be a System.Object? That might obtain the same behavior as dynamic does.
     
  21. Alexzoin

    Alexzoin

    Joined:
    Jan 17, 2019
    Posts:
    2
    Thanks for the reply! It doesn't look like that will work.

    upload_2022-9-20_12-32-56.png
     
  22. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Ahh sorry, I'm not sure that I can help out more then.
     
  23. kyuuzou

    kyuuzou

    Joined:
    Aug 28, 2018
    Posts:
    1
    Does this mean we should avoid using the Python Scripting package's Low Level API? It uses the dynamic keyword on its sample code.
     

    Attached Files:

  24. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I'm not familiar with that library specifically, but it is requires the use of the dynamic keyword, then it won't work well with Unity.
     
  25. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    I am confused here. Are you saying that your own Python scripting package is not going to work well with your own engine? That python package is a Unity provided package, is version 6.x, and is using the dynamic keyword right there on the main page example. (seen below).

    I mean, it seems that Unity *can* make use of the dynamic keyword, has for a few years, and if I remember correctly, that python package is relatively newer and it's main purpose was to provide additional integration with and bring Unity more in line with other major DCC suites. Core functionality of that package seems to rely on the dynamic keyword. It seems like it would be a good idea for it to be properly supported, no?

    That said, it just seems like perhaps there is a disconnect in information, if one team is phasing out a feature, but another team is relying on it, that doesn't seem like it will turn out great.


     
    mdimov likes this.
  26. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I agree, this is not a great situation. I'll try to determine which team at Unity maintains this packages and follow up with them.
     
    mdimov likes this.
  27. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I've chatted a bit with the team that maintains the Python scripting package. As it turns out, that package is only used in the Unity Editor. Because the editor uses a JIT .NET runtime (Mono), the dynamic keyword does work properly there.

    Is there some specific problem though with the Python scripting package and the dynamic keyword?
     
  28. MorganYT

    MorganYT

    Joined:
    Jul 29, 2017
    Posts:
    31
    Then what about this package? Official from Unity, also requires the use "dynamic"

    upload_2023-3-10_0-26-42.png
     
  29. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    I'm not sure who at Unity maintains that package. I think it would be worthwhile to log a bug report against it though, as dynamic certainly won't work in Unity player builds on all platforms.
     
  30. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    This is a joke. We need support for this. It was working fine before for years. How do we pressure Unity into supporting it properly? A bug report?

    We can persist with object to some extent for now.
     
    Last edited: Apr 13, 2023
    Tuntenfisch and lucdouwe like this.
  31. mrkarate

    mrkarate

    Joined:
    Dec 4, 2012
    Posts:
    7
    unity is a joke on this days compared to unreal
     
  32. Postograf

    Postograf

    Joined:
    Aug 31, 2019
    Posts:
    1
    Unity 2022.2.0b14 Mono .Net standart 2.0 project. Just put Microsoft.CSharp.dll to Plugins folder and it work. But in first try get an error like "Two same dll delete one of them" but then after delete dll and put it again all work fine.
     
  33. mmntlh

    mmntlh

    Joined:
    Feb 2, 2019
    Posts:
    11
    Can confirm this is still not supported.
     
  34. NullQubit

    NullQubit

    Joined:
    Jun 1, 2015
    Posts:
    11
    Surely many projects already in production make use of Newtonsoft.Json which does use dynamic to serialize/deserialize types without having to register each one statically, so my guess is that adding Microsoft.CSharp.dll into the project shouldn't introduce any problems. Can anyone confirm?
     
  35. IBN_E_BAQIR

    IBN_E_BAQIR

    Joined:
    Nov 5, 2021
    Posts:
    1
    Thanks, Worked for me
     
  36. lipisis

    lipisis

    Joined:
    Jan 14, 2017
    Posts:
    37
    IL2CPP comment is not accurate. IL2CPP does not support
    dynamic
    keyword. See official docs. With this in mind, if you are planning to publish your game on, say, iOS,
    dynamic
    will never work. See scripting backend part of those docs.

    If you are publishing on PC or Android (but with Mono scripting backed), then you're all good. Otherwise, you can't use
    dynamic
    .

    Here's snippet from Microsoft docs about IL2CPP limitations
     
  37. ILonion

    ILonion

    Joined:
    Oct 26, 2015
    Posts:
    73
    @JoshPeterson
    I'm passing different custom classes to 1 method using dynamic (currently editor 2020.3.48lts, PC, mono, net 4.x)
    Would you have recommendations for workarounds, given that this is a known incompatibility (dynamic) ?
     
  38. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
    You should be able to just use the standard C# object, or make it a generic method?

    Code (CSharp):
    1. public object myCustomClasses;
    Something like this?

    Code (CSharp):
    1. public void MyMethod<T>(T customClass) where T: class {}
     
    ILonion likes this.
  39. ILonion

    ILonion

    Joined:
    Oct 26, 2015
    Posts:
    73
    @MostHated I have different classes (different names) with same fields (too much serialized data already). Passing them to 1 same method. I need generic method.
     
  40. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    ILonion likes this.