如何在Unity C#脚本中引用ServiceStack库?

Nat*_*han 5 unity-game-engine servicestack

我必须制作一个Unity脚本来导入和导出一些3D模型.我正在尝试从我的脚本中引用Servicestack.Redis,以便我可以与redis交谈.它编译得很好,但统一不会加载库.

我已经将Build/Release/MonoDevelop/SericeStack.Redis.zip中的dll复制到了unity中的assets文件夹中(这是正确的吗?)我只是通过克隆https://github.com/ServiceStack/ServiceStack.Redis来获得ServiceStack

当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)

到目前为止我的代码是这样的.这是一个编辑器脚本.它只是创建一个带有按钮的窗口,当单击该按钮时,它会尝试连接到localhost上的redis并获取密钥

using UnityEngine;
using UnityEditor;
using System.Collections;
using ServiceStack.Redis;

public class MyWindow : EditorWindow
{

    // Add menu item named "My Window" to the Window menu
    [MenuItem("Window/My Window")]
    public static void ShowWindow()
    {
        //Show existing window instance. If one doesn't exist, make one.
        EditorWindow.GetWindow(typeof(MyWindow));
    }

    void OnGUI()
    {
        if (GUILayout.Button("Press to Rotate"))
        {
            ProcessAsset();
        }
    }

    void ProcessAsset()
    {
        using (var client = new RedisClient("localhost"))
        {
            client.Get ("hello");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我可能只是没有正确引用库.我是编译语言的新手.

Lan*_*nge 1

我有一个类似的错误。但它没有任何自定义 dll。原因是因为我在代码中使用了Func 。Mono 不支持Func。我尝试下载 dll 的源代码,它们使用了相当多的 Func。所以这可能是您收到该错误的原因。