Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Unity 5.6.0 and VS 2017] Creating DLL using VS2017

Discussion in 'Editor & General Support' started by Cylosis, Apr 25, 2017.

  1. Cylosis

    Cylosis

    Joined:
    Jun 1, 2016
    Posts:
    2
    Hi,

    I followed lordofduct's post to create a DLL (link : https://forum.unity3d.com/threads/compiling-c-scripts-to-dll-files.318803/) but I face assembly issues.

    When I create a new library project on VS2017 I choose to use .NET 3.5 Framework.
    I imported UnityEngine.dll and other external librairies (such as Newtonsoft.Json) to get my code to work.

    The thing is VS2017 can't find out what is [Serializable]
    CS0246 The type or namespace name 'SerializableAttribute' could not be found (are you missing a using directive or an assembly reference?)
    CS0246 The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)

    I did some research and found out that the namespace that I need is contained in mscorlib.dll. I then added the mscorlib.dll located in C:\Program Files\Unity\Editor\Data\Mono\lib\mono\unity\mscorlib.dll to the project references and then I got these errors on every System object I use :
    CS0518 Predefined type 'System.Object' is not defined or imported.
    CS0518 Predefined type 'System.Void' is not defined or imported.
    ... and so on

    I assume that when imported mscorlib.dll is in conflict with another library somehow. The thing is I did not add any references except references to UnityEngine.dll, Newtonsoft.Json.dll and mscorlib.dll. I think that it might be related to the "SDK references" where a folder NETStandard.Library is located, containing dll such as System dlls such as System.Collections.dll.

    How could I make such a project in VS to work then ?