Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am getting this error whenever I try and run a webjob project with application insight and entity framework.

System.IO.FileLoadException: 'Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

I have installed the following nuget packages

Microsoft.Azure.WebJobs.Logging.ApplicationInsights version 2.1.0-beta4

Microsoft.Extensions.Logging version 2.0.0

Microsoft.Extensions.Logging.Console version 2.0.0.

This all works with a new Visual studio 2017 webjob project, its when I try and include an existing code base, primarily using entity framework that I get this error. When I look at the reference in the one that works I don't have the System.Runtime.InteropServices.RuntimeInformation, yet it has been added to the project with entity framework. It seems to be part of .net standard, but how come I don't need .net standard for my new console app!

enter image description here

I'm not sure why its looking for Version 0.0.0.0 either as the one I have is 4.0.2.0

I have also tried adding this to the project file but this didn't work.

<PropertyGroup>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
   <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

Any help would be greatly appreciated

Many thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
914 views
Welcome To Ask or Share your Answers For Others

1 Answer

Confirming the comment made above by dwilliss also worked for me. The solution was to get rid of:

<dependentAssembly>
  <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>

(In my case from the app.config, for a Windows Service.) My project has an indirect dependency to System.Runtime.InteropServices.RuntimeInformation only. It is a dependency of a NuGet package I imported.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...