Chr*_*ann 1 .net azure visual-studio azure-functions visual-studio-2017
我在 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
Run Code Online (Sandbox Code Playgroud)
请注意,最后一行显示了错误生成函数元数据,并且显示的路径是“netstandard1.0”路径。这看起来是问题的根本原因。但是,这个项目是一个 .NET Framework 4.6.1 项目;不是 .NET Standard 1.0。
您提供的任何建议将不胜感激。另外,一旦我弄清楚了,我会发布我的解决方案。谢谢!
更新 1:我之前引用了一个为 .NET Standard 2.0 构建的 NuGet 包,所以我删除了它的引用,并在“package.config”文件中找到了对 NETStandard 和 NETCore 包的几个引用,所以我删除了那些.
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net461" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="net461" />
Run Code Online (Sandbox Code Playgroud)
删除这 2 个引用并不能解决问题。它似乎仍在尝试构建一个基于 .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 重新下载了文件,但这也没有解决问题。
在解决了可能存在的问题之后,我终于解决了!
显然,Microsoft.Azure.WebJobs.ServiceBus v2.3NuGet 包与基于 .NET Framework 的 Azure Functions v1 不兼容。我删除了 Nuget 引用,然后添加了一个引用,Microsoft.Azure.WebJobs.ServiceBus v2.2构建再次开始工作。向后兼容就这么多!我希望这有助于其他人在出现此问题时解决此问题。
| 归档时间: |
|
| 查看次数: |
580 次 |
| 最近记录: |