There is a problem with newtonsoft.json.dll after adding plastic SCM
A while ago, I opened a new personal project. Because it is a new project, I use the latest ones for everything I want. Therefore, I used plastic SCM officially launched by unity for version control
the plug-in was installed at the beginning. There was nothing wrong with it and it was OK to use. But as the project code piles up, well, the problem arises.
Because I use the powerful newtonsoft. JSON library. After it was added to the project, there was nothing wrong with using it a few days ago and it can be used normally. However, when I used this library in the code of the editor, I referenced the newtonsoft.json namespace and found that the problem came out. Unity kept reporting errors:
There are two in the project newtonsoft.json. This baffled me. After positioning, I found that there is also a newtonsoft.json Library in the plastic SCM package:
good heavens! You also changed someone’s name, # ¥% @# ¥, at least you also changed the namespace… You have a big surprise! Well, I’ll admit it. Who told me to use your stuff
Since you are determined to use it, I’ll think about how to solve it. Because I had no problem in the non editor code before, it may be that the JSON Library in the SCM package itself only runs in the editor mode, and some of the editor codes we wrote refer to the library in the SCM package… Speechless
My current solution:
Option 1:
Delete the original library and copy the in plastic SCM to the project to keep the versions of the two DLLs consistent:
1. Delete the JSON library referenced by ourselves in the project
2. Right click to find the physical path of the JSON Library in plastic SCM:
3. Find it and copy it to the plugins directory of our project, and modify its name as newtonsoft.json.dll
4. Then enter the project and wait for the compilation to be completed
Option 2:
Do not delete the JSON library you put into the project, and keep it coexisting with plastic SCM. However, there are requirements for the storage location of the physical path of the code file because. Asmdef is used.
1. Sort out the code of our editor and create an asmdef file (assembly definition file) in the relative root directory of the code:
For example, in my project, I was working on a level editor, so I sorted the code of the level editor into a levelmaker/scripts directory, and then right-click in the levelmaker directory to create asmdef:
As for sorting the code, if you do well in directory planning in the early stage, there should be no problem. As for how much code an asmdef file contains, it depends on the situation of the project. Some projects are more fine-grained. As for the code of the editor, I generally like to divide it by each tool.
2. After creating the. Asmdef file, unity will enclose our editor code and finally compile it into an independent DLL. Check the override reference option in the setting of. Asmdef, and the assembly references setting item will appear:
3. Add a reference to the dot product + sign, select the DLL file we need to specify the reference, and wait for compilation after applying
4. Finally, don’t forget to check the platform option in the settings, otherwise there will be problems in compiling when publishing
Option 3:
This method is not recommended because I haven’t used it. Just think of
Copy the plastic SCM separately, which is not maintained by packagesmanager, and put it in the plugins directory, so we can do whatever we want… For example, replace the JSON library it refers to with our own… Well, this sounds a bit like scheme 1… In fact, unity has also modified the JSON library it refers to
I don’t recommend it. After all, packagesmanager maintenance is very good, and any version iteration can be updated as soon as possible… After all, plastic SCM is just a tool
Option 4:
Find the source code of the JSON library, and compile your own JSON library after modification… Um…
newtonsoft. JSON library source code: https://github.com/JamesNK/Newtonsoft.Json
Read More:
- c# Newtonsoft.Json.JsonReaderException: ‘Error reading JArray from JsonReader. Path ‘‘, line 0
- There is a problem of DLL when executing G + + compile command in sublime text editor
- A solution to the problem that the number of nodes does not increase and the name of nodes is unstable after adding nodes dynamically in Hadoop cluster
- 【ipfs-api】npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
- [OpenGL] cannot start this program because the computer is missing glut32.dll. Try to re install the program to fix this problem. …
- Unit Android converts c# class to JSON file and reports an error
- About adding legacy to linker additional dependencies_ stdio_ definitions.lib Solve the problem of incomplete standard library files
- OpenGL program running prompt glut32.dll missing problem
- Object is JSON, and JSON is converted to object
- To solve the problem of failed to load: data in HTML5 game running rmmv locally/ actors.json problem
- This program cannot be started because vcruntime140 is missing from your computer_ 1.dll。 Try to install the program again to solve the problem.
- [unity] when using unity hub, there is a problem of “failed to delete old unit installation file…” problem
- Adding project folder in SourceInsight is empty
- Configuration file for vscode setting.json UI interface or JSON form
- Windows Realtek USB wireless network card boot failure Rtlihvs. DLL module stop problem
- Using Visual Studio 2015 to create. DLL and use. DLL
- Solution to the problem that OpenGL can’t find glew32.dll in vs2019
- [jQuery] jQuery operates on JSON strings or JSON objects
- JSON data format net.sf.json .JSONException: A JSONObject text must begin with ‘{‘ at character 1 of Error:(f…
- JQuery is a solution to the disappearance of listening events after adding elements with append