在Unity3d中运行REST服务器

the*_*oom 8 rest unity-game-engine nancy

我正在尝试在Unity项目中构建一个REST服务器,并且最初认为Nancy似乎是明显的选择.然而,许多令人头疼的事情,我仍然无法让Nancy在Unity Mono运行时运行 - 我可以从Xamarin编译和运行但是Unity在我尝试使用资产时给了我相当无益的输出:

Internal compiler error. See the console log for more information. output was:
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 
Run Code Online (Sandbox Code Playgroud)

我不能成为唯一一个尝试过这样的东西的人,我希望在几个项目中使用它,所以有一些可重复使用的东西是高优先级的 - 有没有人成功地实现了这样的东西,如果是这样的话,你能不能给我指点什么?

我真的很想让Nancy工作,但另一种轻松嵌入REST服务器的方式同样有价值.

Ami*_*iri 0

根据Unity Answers 上的这个帖子,发生这种情况是因为 Unity 使用的 .NET 子集不包括 System.Web,因此将 System.Web.dll v2.0.50727 复制到项目中解决了这个问题。

不过,如果没记错的话,我记得 Unity 中的一个选项可以强制它使用完整的 .NET 2.0 运行时而不是子集,这也可能解决问题。我已经有一段时间没有使用 Unity,所以该选项可能已被删除。

编辑: 看到这里它被称为“兼容性级别”。

编辑2:它在播放器设置中