gpt4 book ai didi

c# - SSIS 脚本任务 : Could not load file or assembly 'Microsoft. WindowsAzure.Storage,版本 = 5.0.0.0,文化 = 中性

转载 作者:行者123 更新时间:2023-11-30 23:07:22 24 4
gpt4 key购买 nike

我正在使用 SSDT(Sql Server 数据工具)和 Visual Studio 2015 开发一个 SSIS 项目,我在脚本任务中引用 dll Microsoft.WindowsAzure.Storage.dll 并在我的项目中使用 C#,但它一直抛出以下消息:

Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

我已经尝试使用 Windows PowerShell 取消阻止 DLL,在 Windows 上注册 dll,检查我是否已将 dll 复制到项目文件夹的 bin 目录中,但根本没有结果。

public void Main()
{
// TODO: Add your code here
string srcBlob = (string) Dts.Variables["User::dBlobName"].Value;
// Substitui o nome da pasta PROCESSAR para PROCESSADOS
string destBlobName = srcBlob.Replace((string)Dts.Variables["$Project::dSrcBlobDirectory"].Value, (string)Dts.Variables["$Project::dDestBlobDirectory"].Value);
string srcContainerName = (string)Dts.Variables["$Project::dBlobContainer"].Value;
string accountName = (string)Dts.Variables["$Project::dStorageAccountName"].Value;
//byte[] storageAccessKey = Encoding.ASCII.GetBytes((string) Dts.Variables["$Project::dStorageAccessKey"].Value);
string storageAccessKey = (string)Dts.Variables["$Project::dStorageAccessKey"].Value;

MoveBlobInSameStorageAccount(accountName, storageAccessKey, srcContainerName, srcBlob, destBlobName);

Dts.TaskResult = (int)ScriptResults.Success;
}

static void MoveBlobInSameStorageAccount(string accountName, string accountKey, string containerName, string sourceBlobName, string destBlobName)
{
var cred = new StorageCredentials(accountName, accountKey);
var account = new CloudStorageAccount(cred, true);
var client = account.CreateCloudBlobClient();
var sourceContainer = client.GetContainerReference(containerName);
var sourceBlob = sourceContainer.GetBlockBlobReference(sourceBlobName);
var destinationContainer = client.GetContainerReference(containerName);
var destinationBlob = destinationContainer.GetBlockBlobReference(destBlobName);
destinationBlob.StartCopy(sourceBlob);
sourceBlob.Delete(DeleteSnapshotsOption.IncludeSnapshots);
}

你能帮忙吗?

最佳答案

我之前使用 HttpClient 调用 Blob Storage REST API。根据您的描述,您正在使用 Microsoft Azure Storage Client Library for .NET ,我假设程序集无法正确加载,因为它不在 GAC 中。您可能需要利用 AppDomain.AssemblyResolve加载程序集的事件处理程序,更详细的教程,可以引用How to load an Assembly in a SSIS script task that isn’t in the GAC .

关于c# - SSIS 脚本任务 : Could not load file or assembly 'Microsoft. WindowsAzure.Storage,版本 = 5.0.0.0,文化 = 中性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47393477/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com