我在Visual Studio 2017中有一个Azure Functions v1项目(ala .NET Framework)。它可以构建/编译很长时间,现在,它给出以下FileNotFoundException抱怨说找不到'Microsoft.Azure。 WebJobs的v2.2。这个项目正在构建的东西就很好了,然后突然出现了这个错误。
过去,我会关闭Visual Studio,然后重新打开它,然后构建就可以了。甚至即使您清洁解决方案,构建也可以正常工作。现在的问题是无论执行什么操作都会出现此错误。我什至重新启动了计算机!
这是Visual Studio 2017中显示的Azure Functions v1项目的完整编译器异常:
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。
非常感谢您提供的任何建议。另外,一旦解决方案确定,我将发布解决方案。谢谢!
更新1 :我以前引用了为.NET Standard 2.0构建的NuGet程序包,因此我删除了该引用,并在“ package.config”文件,所以我删除了这些文件。
<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。
更新2 :我尝试删除构建异常中引用的C:\Users\chris\.nuget\packages\microsoft.net.sdk.functions
本地文件夹,以查看是否可以通过从Nuget重新下载构建文件来“解决”该问题适用于Azure Functions v1;这是引发异常的构建脚本。 Visual Studio确实从Nuget重新下载了文件,但这也不能解决问题。
答案 0 :(得分:2)
解决可能存在的问题之后,我终于解决了问题!
显然,Microsoft.Azure.WebJobs.ServiceBus v2.3
NuGet软件包与基于.NET Framework的Azure Functions v1不兼容。我删除了Nuget参考,然后添加了对Microsoft.Azure.WebJobs.ServiceBus v2.2
的参考,构建再次开始工作。向后兼容性就这么多!我希望这可以帮助其他人解决此问题。