小编Ald*_*lde的帖子

Unity“多个同名预编译程序集”使用外部dll

我有一个“共享”项目,我在我的客户端(统一)和我的服务器(C# 服务器)之间共享代码

两个项目都需要 Newtonsoft.Json.dll


当我编译 Shared.dll 并将其放在 Unity 的 Resources 文件夹中时(因此它包含在构建中),我收到此错误:

PrecompiledAssemblyException: Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included or the current platform. Only one assembly with the same name is allowed per platform. Assembly paths: 
Assets/Resources/Shared/Newtonsoft.Json.dll
C:/Users/rotmg/Documents/GitHub/AG-LNL/AG-LNL-Client/Library/PackageCache/com.unity.nuget.newtonsoft-json@2.0.0-preview/Runtime/Newtonsoft.Json.dll
Run Code Online (Sandbox Code Playgroud)

我意识到这是 Unity 对 Newtonsoft.Json 和我的 Shared.dll 的依赖之间的冲突。


这个答案:

https://answers.unity.com/questions/1697304/how-to-resolve-multiple-precompiled-assemblies-err.html

说要使用“将所有依赖项合并到一个 .dll 中”

因此,我尝试使用 Costura.Fody 构建一个捆绑所有依赖项的单个 .dll,但随后出现错误,提示我应该添加对 Shared 依赖项的引用。(NLog、BouncyCastle 等)


我该如何解决这个冲突?

c# unity-game-engine

5
推荐指数
3
解决办法
9378
查看次数

标签 统计

c# ×1

unity-game-engine ×1