编译Azure函数v1(.NET Framework)为Microsoft.Azure.WebJobs提供FileNotFoundException [英] Compiling Azure Function v1 (.NET Framework) gives FileNotFoundException for Microsoft.Azure.WebJobs

查看:55
本文介绍了编译Azure函数v1(.NET Framework)为Microsoft.Azure.WebJobs提供FileNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2017中有一个Azure Functions v1项目(ala .NET Framework).它可以构建/编译很长时间,现在,它给出以下FileNotFoundException抱怨说找不到'Microsoft.Azure.WebJobs的v2.2.这个项目正在构建的东西就很好了,然后突然出现了这个错误.

I have an Azure Functions v1 project (ala .NET Framework) in Visual Studio 2017. It would build / compile just fine for a long time, now it's giving the following FileNotFoundException complaining it can't find 'Microsoft.Azure.WebJobs' v2.2. The thing it this project was building just fine, then all of a sudden this error is occurring.

过去,我会关闭Visual Studio,然后重新打开它,然后构建就可以了.甚至即使您清洁解决方案,构建也可以正常工作.现在的问题是,无论我做什么,我都会收到此错误.我什至重新启动了计算机!

In the past I would close Visual Studio, then reopen it and the build would work. Or even if you Clean the solution, the build would then work. The problem is now I get this error no matter what I do. I've even restarted the computer!

这是Visual Studio 2017中显示的Azure Functions v1项目的完整编译器异常:

Here the full compiler exception displayed in Visual Studio 2017 for the Azure Functions v1 project:

Severity    Code    Description Project File    Line    Suppression State
Error       System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Azure.WebJobs, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Azure.WebJobs, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
   at System.Attribute.InternalGetAttributeUsage(Type type)
   at System.Attribute.InternalParamGetCustomAttributes(ParameterInfo param, Type type, Boolean inherit)
   at MakeFunctionJson.ParameterInfoExtensions.GetDisabledAttribute(ParameterInfo parameterInfo)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 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.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
   at MakeFunctionJson.FunctionJsonConverter.TryRun()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Error generating functions metadata
    Company.Assembly    C:\Users\chris\.nuget\packages\microsoft.net.sdk.functions\1.0.24\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets    41  

注意,最后一行显示了生成函数元数据的错误,并且显示的路径是"netstandard1.0"路径.这似乎是问题的根本原因.但是,此项目是.NET Framework 4.6.1项目;请参阅参考资料.而不是.NET Standard 1.0.

Notice the last line shows an error generating functions metadata and the path displayed is a 'netstandard1.0' path. This looks to be the root cause of the problem. However, this project is a .NET Framework 4.6.1 project; not .NET Standard 1.0.

非常感谢您提供的任何建议.另外,一旦解决方案确定,我将发布解决方案.谢谢!

Any suggestions you have to offer would be greatly appreciated. Also, I'll post my solution once I get it figured out. Thanks!

更新1 :我以前引用了为.NET Standard 2.0构建的NuGet程序包,因此我删除了该引用,并在"package.config"文件,所以我删除了这些文件.

Update 1: I had previously referenced a NuGet Package that was built for .NET Standard 2.0, so I removed the reference for that, and found a couple references to NETStandard and NETCore packages within the 'package.config' file, so I removed those.

<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net461" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="net461" />

删除这两个引用无法解决该问题.似乎它仍在尝试构建基于.NET Framework的Azure Functions v1项目,就好像它是.NET Standard 1.0.

Removing those 2 references did NOT work to fix the problem. It seems it's still trying to build a .NET Framework based Azure Functions v1 project as if it were .NET Standard 1.0.

更新2 :我尝试删除 C:\ Users \ chris \ .nuget \ packages \ microsoft.net.sdk.functions 本地文件夹中引用的本地文件夹生成异常,以查看是否可以通过从Nuget重新下载Azure Functions v1的生成文件来解决"该问题;这是引发异常的构建脚本.Visual Studio确实从Nuget重新下载了文件,但这也不能解决问题.

Update 2: I tried deleting the C:\Users\chris\.nuget\packages\microsoft.net.sdk.functions local folder that is referenced in the build exception to see if that would "fix" the issue by re-downloading from Nuget the build files for Azure Functions v1; this is the build script that's throwing the exception. Visual Studio did re-download the files from Nuget, but this did NOT fix the problem either.

推荐答案

解决了可能存在的问题之后,我终于解决了它!

After going around and around with what could possibly be the issue, I finally fixed it!

显然, Microsoft.Azure.WebJobs.ServiceBus v2.3 NuGet软件包与基于.NET Framework的Azure Functions v1不兼容.我删除了Nuget引用,然后添加了对 Microsoft.Azure.WebJobs.ServiceBus v2.2 的引用,然后该构建再次开始工作.向后兼容性就这么多!我希望这可以帮助其他人解决此问题.

Apparently, the Microsoft.Azure.WebJobs.ServiceBus v2.3 NuGet Package is NOT compatible with .NET Framework based Azure Functions v1. I removed the Nuget reference then added a reference to Microsoft.Azure.WebJobs.ServiceBus v2.2 and the build started working again. So much for backwards compatibility! I hope this helps others fix this issue when it arises.

这篇关于编译Azure函数v1(.NET Framework)为Microsoft.Azure.WebJobs提供FileNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆