Use dynamic keyword function / .NET 4.6 in Unity

I am trying to implement GraphQL in Unity3D (version 2017.1.0f3 Personal). I am using .NET 4.6 (Experimental), but despite this, Unity does not support the dynamic keyword. Which is strange, since .NET 4.0 is part of .NET. Except Unity. I was looking for some solution, how to make it work, but no solutions for a dynamic keyword. The error is this:

Severity    Code    Description Project File    Line    Suppression State
Error   CS1980  Cannot define a class or member that utilizes 'dynamic' 
because the compiler required type 
'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you 
missing a reference?    skiing-prototype (1)    D:\skiing-prototype 
(1)\Assets\Scripts\GraphQL.cs   62  Active

This is the only caveat against using the GraphQL C # client. Has anyone else tried this to make it work? I did not make any more effort to launch it and run it.

EDIT:

I use this client here: https://github.com/bkniffler/graphql-net-client

This is also an error from visual studio, but errors are also displayed in the Unity console, what will be updated for a moment

Assets/Scripts/GraphQL.cs(80,16): error CS1980: Dynamic keyword requires 
`System.Runtime.CompilerServices.DynamicAttribute' to be defined. Are you 
missing System.Core.dll assembly reference?

this is a unity editor error that seems to be the same as in visual studio

+6
source share
2 answers

The first step is to check if Unity recognizes these 2 core C # 6 functions from the MS website .

1 . Try the index initializer function:

private Dictionary<int, string> webErrors = new Dictionary<int, string>
{
    [404] = "Page not Found",
    [302] = "Page moved, but left a forwarding address.",
    [500] = "The web server can't come out to play today."
};

2 . Row Interpolation function:

private string FirstName = "";
private string LastName = "";
public string FullName => $"{FirstName} {LastName}";

If they throw an error, then the problem is not , but in the simple keyword dynamic, but that Visual Studio cannot recognize the version of .NET installed by Unity.

Unity .


. .

1. → → → → → → (.Net 4.6 ).

2. → → → → → API ->.NET 4.6

3. Unity Editor Visual Studio. .

# . , dynamic . , # 4.

4. Visual Studio. . Visual Studio /.

5. # 6, , , Visual Studio Unity, 1 2, .

6. , # 6, - , Unity 2017.1 Unity 2017.2. .NET.

, Unity 2017.2 dynamic - . , GraphQL .

+9

,

Edit > Project Settings > Player > Other Settings > Configuration > API Compatibility Level .NET Standard 2.0 .NET 4.x

, dynamic.

,

0

Source: https://habr.com/ru/post/1683441/


All Articles