简体   繁体   English

如何为Unity安装Microsoft.Azure.Devices NuGet包?

[英]How to install Microsoft.Azure.Devices NuGet package for Unity?

I was working with Unity and Hololens and tried to establish connection to Azure Iot Hub via MQTT protocol. 我正在使用Unity和Hololens,并尝试通过MQTT协议建立与Azure Iot Hub的连接。 Microsoft provides a tutorial for getting started with Azure IoT Hub in C# , but unfortunately, I encountered a problem with the tutorial: Microsoft提供了一个在C#中开始使用Azure IoT Hub的教程 ,但不幸的是,我遇到了教程的问题:

在此输入图像描述

In the picture above, I have selected Microsoft.Azure.Device NuGet package for installation. 在上图中,我选择了Microsoft.Azure.Device NuGet包进行安装。 I have tried version 1.0.0 and also the latest one available, 1.2.4. 我已经尝试了1.0.0版本以及最新版本1.2.4。 The projects were automatically generated by Unity and that is probably the reason, why I do encounter this problem. 这些项目是由Unity自动生成的,这可能是我遇到此问题的原因。 Which problem? 哪个问题? After I try to install the selected NuGet, I encounter the following error: 我尝试安装选定的NuGet后,遇到以下错误:

Could not install package 'Microsoft.Azure.Devices 1.2.4'. 无法安装包'Microsoft.Azure.Devices 1.2.4'。 You are trying to install this package into a project that targets '.NETFramework,Version=v3.5,Profile=Unity Full v3.5', but the package does not contain any assembly references or content files that are compatible with that framework. 您正在尝试将此软件包安装到以“.NETFramework,Version = v3.5,Profile = Unity Full v3.5”为目标的项目中,但该软件包不包含与该框架兼容的任何程序集引用或内容文件。 For more information, contact the package author. 有关更多信息,请与软件包作者联系。

I was like, "Hmm, I must have wrong .NET framework version. I wonder if I can change that..." I tried to go to project properties like this 我当时想,“嗯,我必须有错误的.NET框架版本。我想知道我是否可以改变它...”我试图去像这样的项目属性

在此输入图像描述

Microsoft advises changing .NET framework from Properties context menu item: https://technet.microsoft.com/fi-fi/library/bb772098(v=vs.90).aspx (4.24.2017) https://msdn.microsoft.com/en-us/library/bb398202(v=vs.100).aspx (4.24.2017) Microsoft建议从属性上下文菜单项更改.NET框架: https ://technet.microsoft.com/fi-fi/library/bb772098(v = vs。90)。aspx(4.24.2017) https://msdn.microsoft .com / zh-CN / library / bb398202(v = vs.100).aspx (4.24.2017)

However, this feature must be blocked by something, because the view that is supposed to open flashes white and disappears immediately. 但是,此功能必须被某些东西阻止,因为应该打开的视图会闪烁白色并立即消失。 I suppose Unity doesn't like people tinkering with project properties, but what else can I do? 我想Unity不喜欢人们修改项目属性,但我还能做些什么呢? Incompatible .NET framework issue needs to be resolved, so that the NuGet package can be installed, but how do I do that? 需要解决不兼容的.NET框架问题,以便可以安装NuGet包,但我该怎么做?

In short, how to install Microsoft.Azure.Devices NuGet package for Unity? 简而言之, 如何为Unity安装Microsoft.Azure.Devices NuGet包?

Sorry, this isn't possible due Unity's restriction to .net 3.5. 抱歉,由于Unity对.net 3.5的限制,这是不可能的。

To be exactly, they use a custom version of mono-2. 确切地说,他们使用mono-2的自定义版本。


You could try the new (experimental) .net 4.6 settings in Unity 5.6. 您可以在Unity 5.6中尝试新的(experimental) .net 4.6设置。

https://forum.unity3d.com/threads/upgraded-mono-net-in-editor-on-5-5-0b4.433541/ https://forum.unity3d.com/threads/upgraded-mono-net-in-editor-on-5-5-0b4.433541/

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM