Visual Studio 2017 - Could not load file or assembly 'System.Runtime, Version=4.1.0.0' or one of its dependencies

前端 未结 25 2683
轻奢々
轻奢々 2020-11-28 22:52

I am using Visual Studio 2017 and am trying to create a .Net Standard 1.5 library and use it in a .Net 4.6.2 nUnit test project.

I am getting the following error...

25条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 23:29

    I resolved that error by referencing the NetStandard.Library and the following app.config File in the NUnit-Project.

    
    
    
        
            
                
                
            
            
                
                
            
            
                
                
            
        
    
    

    Edit

    If anything other than System.Runtime, System.Reflection or System.Runtime.InteropServices is missing (e.g. System.Linq), then just add a new dependentAssembly node.

    Edit 2

    In new Visual Studio Versions (2017 15.8 I think) it's possible that Studio creates the app.config File. Just check the Auto-generate binding redirects Checkbox in Project-Properties - Application.

    Edit 3

    Auto-generate binding redirects does not work well with .NET Classlibraries. Adding the following lines to the csproj files solves this and a working .config file for the Classlibary will be generated.

    
      true
      true
    
    

提交回复
热议问题