[英]SSIS - Unable to load DLL 'clrcompression.dll': The specified module could not be found
我需要在 SSIS 中壓縮數據文件夾。 為此,我使用運行此腳本的腳本任務:
public void Main()
{
// TODO: Add your code here
try
{
string zipPath = (string)Dts.Variables["User::sFolderCompressed"].Value;
string startPath = (string)Dts.Variables["User::sFolderSource"].Value;
ZipFile.CreateFromDirectory(startPath, zipPath);
}
catch (Exception objException)
{
Dts.TaskResult = (int)ScriptResults.Failure;
// Log the exception
}
Dts.TaskResult = (int)ScriptResults.Success;
}
我設置的 2 個變量:
執行腳本任務步驟給了我以下錯誤:
{System.DllNotFoundException:無法加載 DLL 'clrcompression.dll':找不到指定的模塊。 (來自 HRESULT 的異常:0x8007007E)在 Interop.inflateInit2_(Byte* stream, Int32 windowBits, Byte* version, Int32 stream_size) at System.IO.Compression.ZipFile.Open(String archiveFileName, ZipArchiveMode mode, Encoding entryNameEncoding) at System.IO .Compression.ZipFile.DoCreateFromDirectory(String sourceDirectoryName, String destinationArchiveFileName, Nullable`1 compressionLevel, Boolean includeBaseDirectory, Encoding entryNameEncoding) 在 System.IO.Compression.ZipFile.CreateFromDirectory(String sourceDirectoryName, String destinationArchiveFileName) 在 ST_19ce97c462f844855412Mainec8448554162f84485554162f84485554125415412 c:\\Users\\SQL\\AppData\\Local\\Temp\\3\\Vsta\\46892b1db29f45f2a8e1fb8c5d37a542\\ScriptMain.cs:line 104}
錯誤消息非常清楚,我在某處丟失了“clrcompression.dll”文件。 我可以只下載這個 DLL 嗎? 我應該把它復制到哪里?
更新
添加了“執行流程任務”並設置以下內容:
Executable : 'powershell.exe'
Arguments : -nologo -noprofile
-command "Compress-Archive -Path E:\Flat Files\IT\StockAge\Stock Age Difference\MAINCHECKK807Babbage\BabbageStockAgeingPartno.csv
-DestinationPath E:\Flat Files\IT\StockAge\Stock Age Difference\MAINCHECKK807Babbage\BabbageStockAgeingPartno.zip"
但得到錯誤:
[執行流程任務] 錯誤:在執行“powershell.exe”“-nologo -noprofile -command”“Compress-Archive -Path E:\\Flat Files\\IT\\StockAge\\Stock Age Difference\\MAINCHECKK807Babbage\\BabbageStockAgeingPartno.csv -DestinationPath E: \\Flat Files\\IT\\StockAge\\Stock Age Difference\\MAINCHECKK807Babbage\\BabbageStockAgeingPartno.zip"" at "",進程退出代碼為“1”,而預期為“0”。
更新 2
在 PowerShell 中執行腳本會出現以下錯誤。
腳本任務只能訪問已在GAC 中注冊或已在腳本中手動加載的 DLL。 如果要使用腳本任務,則需要加載 DLL 以使腳本能夠運行
或者,對於基本的 zip 功能,您可以使用命令行工具並從執行流程任務中調用它。 如果您安裝了最新的 Windows 服務器並安裝了所有 .net 框架,您可以嘗試 PowerShell 方法,否則使用 7zip 方法
PowerShell Zip 方法
設置執行任務,以便它調用 PowerShell 並在參數中傳遞您的 zip 指令
Executable = 'powershell.exe'
Arguments = Powershell -nologo -noprofile -command 'Compress-Archive -Path \"C:\SO\Test Folder\Test.txt\" -DestinationPath \"C:\SO\Test Folder\Test.zip\"'
編輯 1
如果您的路徑有空格,那么您需要使用反斜杠和雙引號將它們轉義
你的論點應該是
-nologo -noprofile -command 'Compress-Archive -Path \"E:\Flat Files\IT\StockAge\Stock Age Difference\MAINCHECKK807Babbage\BabbageStockAgeingPartno.csv\" -DestinationPath \"E:\Flat Files\IT\StockAge\Stock Age Difference\MAINCHECKK807Babbage\BabbageStockAgeingPartno.zip\"'
編輯 2
要調試該命令,請嘗試在 PowerShell 中運行它,如下所示,看看是否有任何其他信息
7郵編方法
在將運行此軟件包的所有服務器上安裝 7zip 64bit
您需要確保服務器之間的安裝目錄匹配,否則 ssis 在部署時將找不到可執行文件
Executable = C:\Program Files\7-Zip\7z.exe
Arguments = a -r "C:\SO\Test Folder\Test.zip" "C:\SO\Test Folder\Test.txt"
clrcompression.dll是 .NET Framework 的一部分。
我認為您需要檢查機器上的 .NET Framework 安裝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.