Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SSIS脚本任务:无法加载文件或程序集';Microsoft.WindowsAzure.Storage,版本=5.0.0.0,区域性=中性_C#_Sql Server_Ssis_Azure Storage Blobs_Etl - Fatal编程技术网

C# SSIS脚本任务:无法加载文件或程序集';Microsoft.WindowsAzure.Storage,版本=5.0.0.0,区域性=中性

C# SSIS脚本任务:无法加载文件或程序集';Microsoft.WindowsAzure.Storage,版本=5.0.0.0,区域性=中性,c#,sql-server,ssis,azure-storage-blobs,etl,C#,Sql Server,Ssis,Azure Storage Blobs,Etl,我正在使用SSDT(Sql Server数据工具)和Visual Studio 2015处理一个SSIS项目,我正在脚本任务中引用dll Microsoft.WindowsAzure.Storage.dll,并在我的项目中使用C#,但它不断抛出以下消息: 无法加载文件或程序集“Microsoft.WindowsAzure.Storage,版本=5.0.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。系统找不到指定的文件 我已经尝试使用Wind

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

无法加载文件或程序集“Microsoft.WindowsAzure.Storage,版本=5.0.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。系统找不到指定的文件

我已经尝试使用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存储REST API。根据您的描述,您正在使用,我假设程序集无法正确加载,因为它不在GAC中。您可能需要利用事件处理程序加载程序集,您可以参考更详细的教程。

您可以将dll(包括Microsoft.WindowsAzure.Storage.dll)添加到Azure SSIS运行时,如下所述:


感谢您的研究:

您是最棒的!非常感谢。尝试删除程序集引用,然后将其添加回-我遇到了一些问题,因为未知原因引用了错误的版本