.net Azure函数v1错误System.IO.FileNotFoundException:无法加载文件或程序集';Microsoft.Azure.WebJobs

.net Azure函数v1错误System.IO.FileNotFoundException:无法加载文件或程序集';Microsoft.Azure.WebJobs,.net,azure-functions,.net,Azure Functions,我创建了一个azure函数,一切正常。但一旦我添加了另一个项目引用,我就会得到这个构建错误 Severity Code Description Project File Line Suppression State Error System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Azure.WebJobs, Version=2.3.0.0, Culture=ne

我创建了一个azure函数,一切正常。但一旦我添加了另一个项目引用,我就会得到这个构建错误

Severity    Code    Description Project File    Line    Suppression State
Error       System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Azure.WebJobs, Version=2.3.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.3.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     C:\Users\xxx\.nuget\packages\microsoft.net.sdk.functions\1.0.24\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets  41  
严重性代码描述项目文件行抑制状态
错误System.IO.FileNotFoundException:无法加载文件或程序集“Microsoft.Azure.WebJobs,版本=2.3.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。系统找不到指定的文件。
文件名:“Microsoft.Azure.WebJobs,版本=2.3.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35”
在System.ModuleHandle.ResolveType(运行时模块模块、Int32 typeToken、IntPtr*typeInstArgs、Int32 typeInstCount、IntPtr*methodInstArgs、Int32 methodInstCount、ObjectHandleOnStack类型)
位于System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule模块、Int32 typeToken、RuntimeTypeHandle[]TypeInstanceContext、RuntimeTypeHandle[]MethodInstanceContext)
位于System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken,类型[]genericTypeArguments,类型[]genericMethodArguments)
在System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord,MetadataImport作用域,Assembly&LastAptCookAssembly,RuntimeModule decoratedModule,MetadataToken decoratedToken,RuntimeType attributeFilterType,Boolean必须不可编辑,Object[]属性、IList-derivedAttributes、RuntimeType和attributeType、IRontimeMethodInfo和ctor、Boolean和ctorHasParameters、Boolean和isVarArg)
位于System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule、Int32 decoratedMetadataToken、Int32 pcaCount、RuntimeType attributeFilterType、Boolean mustBeInheritable、IList derivedAttributes、Boolean isDecoratedTargetSecurityTransparent)
位于System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType类型、RuntimeType类型、布尔继承)
位于System.Attribute.InternalGetAttributeUsage(类型)
位于System.Attribute.InternalParamGetCustomAttributes(ParameterInfo-param,类型类型,布尔继承)
在MakeFunctionJson.ParameterInfo扩展名.GetDisabledAttribute(ParameterInfo ParameterInfo)
在System.Linq.Enumerable.WhereSelectArrayInterator`2.MoveNext()中
位于System.Linq.Enumerable.WhereEnumerableInterator`1.MoveNext()
位于System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1源)
在MakeFunctionJson.MethodInfoExtensions.GetDisabled(MethodInfo方法)
在MakeFunctionJson.MethodInfoExtensions.hasunPortedAttributes(MethodInfo方法、字符串和错误)
在MakeFunctionJson.FunctionJsonConverter.d__9.MoveNext()中
位于System.Collections.Generic.List`1..ctor(IEnumerable`1集合)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
在MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()中
在MakeFunctionJson.FunctionJsonConverter.TryRun()处
警告:程序集绑定日志记录已关闭。
要启用程序集绑定失败日志记录,请将注册表值[HKLM\Software\Microsoft\Fusion!EnableLog](DWORD)设置为1。
注意:程序集绑定失败日志记录会带来一些性能损失。
要关闭此功能,请删除注册表值[HKLM\Software\Microsoft\Fusion!EnableLog]。
生成函数元数据C:\Users\xxx\.nuget\packages\microsoft.net.sdk.functions\1.0.24\build\netstandard1.0\microsoft.net.sdk.functions.build.41时出错
下面是我的csproject文件

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net462</TargetFramework>
    <AzureFunctionsVersion>v1</AzureFunctionsVersion>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\xxxx\vvv.csproj" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Configuration" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

net462
v1
真的
保存最新
保存最新
从未
另请参见以下参考项目的csproject文件(隐藏的缓和信息)


真的
真的
包装参考
vvv
vvv
net462
性质
图书馆
任意CPU
512
2018.09.11.1
xxx
©2018 xxx
xxx
xxx网络462
xxx
vvv(ASP.Net 4.6.2)
真的
满的
假的
bin\Debug\
调试;痕迹
促使
0
真的
pdbonly
真的
bin\Release\
痕迹
促使
0
插件\EntityFramework\EntityFramework.dll
插件\EntityFramework\EntityFramework.SqlServer.dll

此问题仅在添加此项目引用时发生。否则就没有生成错误。我无法找出导致此问题的依赖组件。

将项目的.NET sdk版本更新为引用项目中的相同版本,以便azure.webjobs版本相同。此错误是由于项目中的版本冲突造成的。您可以使用Manage-NuGet-package选项更新.NET sdk。由于冲突,该选项看起来像是某些依赖项加载失败。启用FusionLog并发布输出。要启用程序集绑定失败日志记录,请将注册表值[HKLM\Software\Microsoft\Fusion!EnableLog](DWORD)设置为1。“您好,请显示您的函数和其他项目的.csproj文件。请参阅.Hi@BowmanZhu,在说明中添加了csproj文件。”
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
  </PropertyGroup>

  <PropertyGroup>
    <RootNamespace>vvv</RootNamespace>
    <AssemblyName>vvv</AssemblyName>
    <TargetFramework>net462</TargetFramework>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <OutputType>Library</OutputType>
    <Platforms>AnyCPU</Platforms>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>

  <!-- Nuget & Assembly Information -->
  <PropertyGroup>
    <Version>2018.09.11.1</Version>
    <Company>xxx</Company>
    <Copyright>© 2018 xxx</Copyright>
    <Title>xxx</Title>
    <PackageTags>xxx net462</PackageTags>
    <Authors>xxx</Authors>
    <Description>vvv (ASP.Net 4.6.2)</Description>
  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>0</WarningLevel>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <WarningsAsErrors />
    <CodeAnalysisRuleSet />
  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>0</WarningLevel>
    <CodeAnalysisRuleSet />
  </PropertyGroup>

  <ItemGroup>

    <Reference Include="EntityFramework">
      <HintPath>Plugins\EntityFramework\EntityFramework.dll</HintPath>
    </Reference>
    <Reference Include="EntityFramework.SqlServer">
      <HintPath>Plugins\EntityFramework\EntityFramework.SqlServer.dll</HintPath>
    </Reference>
    <Reference Include="System.Configuration" />
    <Reference Include="System.Web" />
  </ItemGroup>
</Project>