【问题标题】:Why project can't find Microsoft.Azure.WebJobs 3.0.0.0为什么项目找不到 Microsoft.Azure.WebJobs 3.0.0.0
【发布时间】:2019-03-13 11:45:03
【问题描述】:

我在 Visual Studio 15.8.6 中有一个 Azure Functions (v2) 项目,其中安装了 Azure Functions 和 Web Job Tools 5.2.60618.0。我正在使用 ServiceBusTrigger。当我尝试编译项目时,我不断得到:

严重性代码描述项目文件行抑制状态 错误 System.IO.FileNotFoundException:无法加载文件或程序集“Microsoft.Azure.WebJobs,版本=3.0.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。该系统找不到指定的文件。 文件名:'Microsoft.Azure.WebJobs,版本=3.0.0.0,Culture=neutral,PublicKeyToken=null' 在 System.ModuleHandle.ResolveType(RuntimeModule 模块,Int32 typeToken,IntPtr* typeInstArgs,Int32 typeInstCount,IntPtr* methodInstArgs,Int32 methodInstCount,ObjectHandleOnStack 类型) 在 System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule 模块,Int32 typeToken,RuntimeTypeHandle[] typeInstantiationContext,RuntimeTypeHandle[] methodInstantiationContext) 在 System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken,Type[] genericTypeArguments,Type[] genericMethodArguments) 在 System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord,MetadataImport 范围,Assembly 和 lastAptcaOkAssembly,RuntimeModule 装饰模块,MetadataToken 装饰令牌,RuntimeType attributeFilterType,Boolean mustBeInheritable,Object[] 属性,IListderivedAttributes,RuntimeType&attributeType,IRuntimeMethodInfo&ctor,Boolean&ctorHasParameters,Boolean&isVar 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule 装饰模块,Int32 装饰元数据令牌,Int32 pcaCount,RuntimeType attributeFilterType,布尔 mustBeInheritable,IList 派生属性,布尔 isDecoratedTargetSecurityTransparent) 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeParameterInfo 参数,RuntimeType caType) 在 System.Attribute.InternalParamGetCustomAttributes(ParameterInfo 参数,类型类型,布尔继承) 在 MakeFunctionJson.ParameterInfoExtensions.GetDisabledAttribute(ParameterInfo parameterInfo) 在 System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() 在 System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source) at MakeFunctionJson.MethodInfoExtensions.GetDisabled(MethodInfo method) at MakeFunctionJson.MethodInfoExtensions.HasUnsuportedAttributes(MethodInfo method, String& error) at MakeFunctionJson.FunctionJsonConverter.<GenerateFunctions>d__9.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 源) 在 MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons() 在 MakeFunctionJson.FunctionJsonConverter.TryRun()

警告:程序集绑定日志记录已关闭。启用程序集绑定 失败记录,设置注册表值 [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) 为 1。注意:有 是与装配绑定失败相关的一些性能损失 记录。要关闭此功能,请删除注册表值 [HKLM\Software\Microsoft\Fusion!EnableLog]。

错误生成函数元数据 InSysFunctionDeviceMinuteDataProcessorV2 C:\Users\Dr Kurt Richardson.nuget\packages\microsoft.net.sdk.functions\1.0.22\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets 39

虽然它在抱怨缺少Microsoft.Azure.WebJobs 3.0.0.0,但在安装的包中明确列出:

我注意到的一件事是,尽管该项目使用的是 .NET Standard v2.0.3,但错误消息指的是包含 netstandard1.0 的路径(...nuget\packages\microsoft. net.sdk.functions\1.0.22\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets 3) 。 Nuget 表示 Microsoft.NET.Sdk.Functions v1.0.22 的目标是 .NETStandard, Version=v2.0。此外,Microsoft.Azure.WebJobs 位于 netstandard2.0 文件夹中。这可能是问题吗?还是别的什么?

【问题讨论】:

  • 我实际上安装了 15.9.02009.0 的 Azure Functions 和 Web 作业工具 - 不知道我从哪里提取了 5.2.60618.0。哦。

标签: c# azure azure-functions


【解决方案1】:

package references in v2

Microsoft.Azure.WebJobs.ServiceBus重命名Microsoft.Azure.WebJobs.Extensions.ServiceBusMicrosoft.Azure.WebJobs包含在Microsoft.NET.Sdk.Functions中,无需单独安装。

请将 Azure Functions 和 Web 作业工具更新为 latest version(现在是 15.10.2009.0)。

使用最新的扩展和模板,当我们创建服务总线触发器时,现在默认的 nuget 依赖项是

Microsoft.Azure.WebJobs.Extensions.ServiceBus v3.0.0
Microsoft.NET.Sdk.Functions v1.0.22

【讨论】:

  • 完美 - 非常感谢。问题在于 Microsoft.Azure.WebJobs.ServiceBus 参考。不确定我从哪里提取 v5.2.60618.0 - 我实际上有 15.9.02009.0,但会按照您的建议进行更新。非常感谢您如此迅速地做出回应——这让我困扰了好几天。我在哪里可以了解到从 Microsoft.Azure.WebJobs.ServiceBus 到 Microsoft.Azure.WebJobs.Extensions.ServiceBus 的变化?
  • @ProfNimrod 抱歉错过了,已添加官方链接。
  • 经历了同样的事情。它发布在 Azure Functions v2 的 GA 发行说明中,并在几个问题中进行了引用。基本上,如果您使用的是 v2,最好从这些问题和发行说明中搜索每一滴内容。有很多这样的小问题。
  • @Jeff 好点。对于 VS 开发,更新 Azure Functions and Web Job Tools 基本上足以满足新功能,而更新 sdk 引用以及 host.json change 应该可以使旧的 v2 功能正常工作。
【解决方案2】:

Microsoft.NET.Sdk.Functions 更新到最新版本

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-07
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 2018-09-11
    • 1970-01-01
    相关资源
    最近更新 更多