1

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.

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!

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  

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!

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" />

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.

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.

1 Answer 1

5

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

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I had one project with the same issue but other projects on v1 were able to use the 2.3 package. Microsoft states that the Microsoft.Azure.WebJobs.Extensions.ServiceBus packages are used for functions v2, and Microsoft.Azure.WebJobs.ServiceBus 2.x for v1: learn.microsoft.com/en-us/azure/azure-functions/…
Had the same issue. AF v1 (Microsoft.NET.Sdk.Functions 1.0.28), got this error once decided to use ILogger on v1. Once downgraded to Microsoft.Azure.WebJobs.ServiceBus v2.2 the app start building, but now it can't initiate ILogger. Still don;t have woring code, looks like beter way remain with TraceWriter on AF v1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.