簡體   English   中英

無法加載文件或程序集“ICSharpCode.SharpZipLib”或其依賴項之一。 訪問被拒絕

[英]Could not load file or assembly 'ICSharpCode.SharpZipLib' or one of its dependencies. Access is denied

存檔正在辦公室和網站上的遠程桌面(同事)上工作。 我測試了它。

我正在寫一個服務,我也需要它。 這不適用於我的機器,我遠程工作並通過VPN連接。 登錄此計算機的用戶屬於該域。

現在,在壓縮之前,我正在使用特殊用戶帳戶進行冒充。 如果我不這樣做,那么這甚至不會在網站上工作。

以下是我得到的例外。 我該如何解決?

System.IO.FileLoadException was caught
  Message=Could not load file or assembly 'ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73' or one of its dependencies. Access is denied.
  Source=Project.Helpers
  FileName=ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73
  FusionLog==== Pre-bind state information ===
LOG: User = Unknown
LOG: DisplayName = ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73
 (Fully-specified)
LOG: Appbase = file:///C:/Users/UserPC/Documents/DATA/Projects/ProjectHelperApps/ProjectHelper/TestResults/UserPC_UserPCJ-LAPTOP 2012-08-03 15_50_57/Out
LOG: Initial PrivatePath = NULL
Calling assembly : Project.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\UserPC\Documents\DATA\Projects\ProjectHelperApps\ProjectHelper\TestResults\UserPC_UserPCJ-LAPTOP 2012-08-03 15_50_57\Out\Project.Helpers.Tests.DLL.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: ICSharpCode.SharpZipLib, Version=0.85.3.365, Culture=neutral, PublicKeyToken=1b03e6acf1164f73
LOG: Attempting download of new URL file:///C:/Users/UserPC/Documents/DATA/Projects/ProjectHelperApps/ProjectHelper/TestResults/UserPC_UserPCJ-LAPTOP 2012-08-03 15_50_57/Out/ICSharpCode.SharpZipLib.DLL.
ERR: A fatal error occurred when retrieving next codebase for download (hr = 0x80070005).

  StackTrace:
       at Project.Helpers.IO.ZipUtility.ZipFiles(String toArchivePath, String destDir, String archiveName, String password, Boolean isDir)
       at Project.Helpers.IO.FileSystem.ArchiveDirectory(String dirToArchive, String destDir, String archiveName)
  InnerException:

這是歸檔方法:

public bool ArchiveDirectory(string dirToArchive, string destDir, string archiveName)
        {
            bool ok = false;

            if (!String.IsNullOrWhiteSpace(dirToArchive) &&
                    !String.IsNullOrWhiteSpace(destDir) &&
                    !String.IsNullOrWhiteSpace(archiveName) &&
                    DirectoryExists(dirToArchive))
            {
                ok = true;
                //create destination directory
                if (!DirectoryExists(destDir))
                    ok = CreateDirectory(destDir);
            }

            if (ok)
            {
                //Archive Name should have .ZIP extension, if not, add it
                if (!archiveName.ToLowerInvariant().Contains(".zip"))
                    archiveName = archiveName + ".ZIP";

                //Check that the Zip file already exists, if it does then delete it
                if (FileExists(Path.Combine(destDir, archiveName)))
                    ok = FileDelete(Path.Combine(destDir, archiveName));
            }

            if (ok)
            {
                //Start Impersonation
                _impersonate.DoImpersonate();

                //Using ZipUtility Class to Zip Directory
                try
                {
                    ZipUtility.ZipFiles(dirToArchive, destDir, archiveName, "", true);
                }
                catch (SystemException ex)
                {
                    ok = false;
                }
                //end impersonation
                _impersonate.Dispose();
            }

            if (ok)
            {
                //double check that the archived directory exists
                ok = FileExists(Path.Combine(destDir, archiveName));
            }

            return ok;
        }

請注意,模擬正在運行,因為CreateDirectory,FileExists和FileDelete正在運行,沒有任何問題。 在執行相關操作之前,這三種方法首先模擬。

感謝您的關注!

通過以下方式解決了這個問題:

  1. 將C的所有權授予管理員組並將其深入到文件級別而不是安裝程序。
  2. 對管理員組的C應用完全控制權限並將其深入到文件級別

在C:\\ Windows \\ Microsoft.NET \\ Framework \\ ... \\ Temporary ASP.NET Files中臨時清理文件夾。

希望這可以提供幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM