点网核心和Azure存储:无法加载文件或程序集系统,版本= 4.0.0.0 [英] Dot Net Core and Azure Storage: Could not load file or assembly System, Version=4.0.0.0

查看:82
本文介绍了点网核心和Azure存储:无法加载文件或程序集系统,版本= 4.0.0.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行在"netcoreapp1.0"上的Web API,该API正在使用Azure存储客户端.访问blob根本没有问题,但是当我尝试对表执行任何操作时,都会引发此错误:

I have a web API running on "netcoreapp1.0" which is using Azure Storage Client. Accessing blobs has no issue at all but when I try execute any operation with tables it throws me this error:

抛出异常:System.Private.CoreLib.ni.dll中的'Microsoft.WindowsAzure.Storage.StorageException'

Exception thrown: 'Microsoft.WindowsAzure.Storage.StorageException' in System.Private.CoreLib.ni.dll

其他信息:无法加载文件或程序集'System,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'.系统找不到指定的文件.

Additional information: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

发生的具体行如下:

如果(等待table.ExistsAsync())

if (await table.ExistsAsync())

即使将其删除,只要它碰到实际上会对Azure进行HTTP调用的行,它仍然会产生相同的结果.我正在导入"net46",并且我也尝试在project.json中导入"net40",但是没有任何变化.

Even removing this, whenever it hits a line where it would actually do a HTTP call to Azure it still results the same. I am importing "net46", and I have tried also importing in my project.json "net40", but no change.

上面的代码位于"Cameo.Azure.Storage.Library"中.它以netstandard1.6为目标,并引用"WindowsAzure.Storage":"7.2.0"和"NETStandard.Library":"1.6.0".

The code above is living in "Cameo.Azure.Storage.Library". It is targeting netstandard1.6 and it is referencing "WindowsAzure.Storage": "7.2.0" and "NETStandard.Library": "1.6.0".

我的project.json在下面:

My project.json is below:

{
  "dependencies": {
    "Cameo.Azure.Storage.Library": "1.0.0-*",
    "Cameo.GeoLocation": "1.0.0-*",
    "LightInject": "4.0.11",
    "LightInject.Microsoft.DependencyInjection": "1.0.1",
    "LocationService.Domain": "1.0.0-*",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Swashbuckle": "6.0.0-beta902"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "net46",
        "net40"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "xmlDoc": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "Areas/**/Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

librarie的project.json

The librarie's project.json

{
  "version": "1.0.0-*",

  "dependencies": {
    "Cameo.Azure.Storage.Interface": "1.0.0-*",
    "LightInject": "4.0.11",
    "Microsoft.Extensions.Configuration": "1.0.0",
    "Microsoft.Extensions.Options": "1.0.0",
    "NETStandard.Library": "1.6.0",
    "WindowsAzure.Storage": "7.2.0"
  },

  "frameworks": {
    "netstandard1.6": {
      "imports": [
        "net46"
      ]
    }
  }
}

推荐答案

将Web API中的project.json更改为此已解决.

Changing the project.json in web API to this has solved the issue.

"frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "portable-net45+win8"
      ]
    }
  }

您只能导入框架的核心或便携式(PCL)版本.参考:

You can only import core or portable (PCL) version of the framework. Reference:

仅对.NET Core和PCL(便携式类库)的版本使用导入"很重要.将其与传统.NET Framework中的TFMS一起使用可能会导致问题或故障.

It is important to use "imports" only for versions of .NET Core and PCL (Portable Class Libraries). Using it with TFMS from the traditional .NET Framework can cause issues or malfunction.

这篇关于点网核心和Azure存储:无法加载文件或程序集系统,版本= 4.0.0.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆