本文介绍了无法为Notification Hub添加绑定(+ nuget问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在尝试创建一个HTTP触发函数,该函数会向所有Android设备发送通知。I'm trying to create an HTTP triggered function that sends a notification to all Android devices.从页面:  https://docs.microsoft。 com / en-us / azure / azure-functions / functions-bindings-notification-hubs,似乎只支持1.x功能。所以我去创建了一个带有HTTP v1功能的新项目。From the page: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-notification-hubs , it seems that only 1.x functions are supported. So I have went and created a new project with an HTTP v1 function.我继续尝试安装NotificationHubs nuget包:  https://www.nuget.org/ packages / Microsoft.Azure.WebJobs.Extensions.NotificationHubs。但是,在我安装nuget包的那一刻,代码似乎没有编译。我收到警告后:I went on and tried to install NotificationHubs nuget package on: https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.NotificationHubs . However, the code doesn't seem to compile the moment I install the nuget package. I'm getting the following warning:警告 NU1602 Microsoft.Azure.NotificationHubs 1.0.7不提供依赖性Microsoft.WindowsAzure.ConfigurationManager的包含性下限。 Microsoft.WindowsAzure.ConfigurationManager 1.7.0的近似最佳匹配已经解决。Warning NU1602Microsoft.Azure.NotificationHubs 1.0.7 does not provide an inclusive lower bound for dependency Microsoft.WindowsAzure.ConfigurationManager. An approximate best match of Microsoft.WindowsAzure.ConfigurationManager 1.7.0 was resolved.当我尝试编译代码时,我收到了"元数据生成失败"错误并且"无法生成加载文件或程序集Microsoft.Azure.WebJobs,Version = 2.2.0.0,....`And when I try to compile the code I'm getting a `Metadata generation failed` error and `Could not load file or assembly Microsoft.Azure.WebJobs, Version=2.2.0.0, ....`在查看nuget包的依赖关系时,我看到了`Microsoft.Azure。 WebJobs.Extensions.NotificationHubs`需要   Microsoft.Azure.NotificationHubs(大于= 1.0.7),但本身需要   Newtonsoft.Json(大于= 10.0.3),但是,功能1.x需要  Newtonsoft.Json(= 9.0.1)。When reviewing the dependencies of the nuget packages, I see that the `Microsoft.Azure.WebJobs.Extensions.NotificationHubs` requires  Microsoft.Azure.NotificationHubs (>= 1.0.7), but that itself requires  Newtonsoft.Json (>= 10.0.3) , however, function 1.x requires Newtonsoft.Json (= 9.0.1).这是我第一次使用nuget包,所以我可能会遗漏一些东西。如何编译和运行我的代码?It is my first time working with nuget packages so I might be missing something. How can I get my code to compile and run? *在我的代码中,我使用以下属性:*In my code, I use the following attribute: 谢谢!推荐答案 使用Microsoft.Azure.NotificationHubs库连接到Azure通知中心。 Use the Microsoft.Azure.NotificationHubs library to connect to the Azure Notification Hub. 默认情况下,通知集线器库位于Azure Functions托管环境中,但未引用。 The notification hubs library is in the Azure Functions hosting environment by default, but not referenced. 为此,请将此行添加到 文件顶部:#r"Microsoft.Azure.NotificationHubs"。包括引号。To do this add this line to the top of your file: #r "Microsoft.Azure.NotificationHubs". Including the quotes.更多信息可以在文档中找到:  https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp#referencing-external-assemblies 。 More info can be found in the documentation: https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp#referencing-external-assemblies. 您可以通过 添加和编辑 project.json文件。You can either doing so byadding and editing a project.json file. 这篇关于无法为Notification Hub添加绑定(+ nuget问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-31 20:21