通过 COM/SxS 在 Unity3d 中使用 .NET 4.0 DLL?
为了简化我的问题,我会尽量简短:
我使用的是专业版 Unity,并且我有 2 个 DLL:
- .NET 3.5 程序集(充当 COM 客户端)
- .NET 4.0 程序集(通过 COM 公开接口)
3.5 使用 COM 与 4.0 一起工作。在 Windows 应用程序中使用 3.5 程序集工作正常,它通过 Type.GetTypeFromCLSID() 或 Type.GetTypeFromProgID() (我已通过 SxStrace 确认)使用 SxS 加载 4.0 dll,并且可以很好地使用它的功能。 (Windows 应用程序通过清单提到它对 4.0 DLL 的依赖,我没有注册 COM DLL。)
我尝试在 Unity 中使用 .NET 4.0 DLL。显然我不能直接使用它,因为Unity使用的Mono当前版本仅支持3.5,因此我创建了3.5程序集作为我的中间人。我可以很好地使用 3.5 程序集,但是我之前提到的任何一个 Type 方法都会抛出 NotImplementedException(s),因为显然 Unity(或者更确切地说,Mono)不支持它们,所以我处于损失。
有什么想法吗?
In an attempt to oversimplify my issue, I'll try to keep it short:
I'm using the pro version of Unity, and I have 2 DLLs:
- A .NET 3.5 assembly (acting as a COM client)
- A .NET 4.0 assembly (with an interface exposed via COM)
The 3.5 uses COM to work with the 4.0. Using the 3.5 assembly in a Windows app works fine, it loads the 4.0 dll using SxS via Type.GetTypeFromCLSID() or Type.GetTypeFromProgID() (which I've confirmed with SxStrace), and can use it's functionality just fine. (The windows app mentions it's dependency on the 4.0 DLL via a manifest, I'm not registering the COM DLL.)
I'm trying to use the .NET 4.0 DLL in Unity. Obviously I can't use it directly, since the current flavor of Mono that Unity uses only supports up to 3.5, thus I created the 3.5 assembly to be my middleman. I'm able to use the 3.5 assembly fine in unity, but either of the Type methods I mentioned before throw NotImplementedException(s), as apparently they aren't supported by Unity (or rather, Mono), so I'm at a loss.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然这个问题是 1 年前提出的……遗憾的是中间人策略仍然不起作用,但不可能在 Unity3D 中使用 .NET 4.0 dll,因为 Mono 不支持依赖项。
如果可能的话,您可以尝试从 dll 中删除任何 4.0 依赖项并将其编译为 3.5。
Although this question was made 1 year ago..sadly the middleman tactic still wont work, it is not possible to use .NET 4.0 dlls within Unity3D since Mono is just not supporting the dependencies.
You could try to remove any 4.0 dependencies from the dll and compile it as 3.5, if that is possible for you.