Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.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# 无法加载文件或程序集';ICSharpCode.SharpZipLib';或者它的一个依赖项。访问被拒绝_C#_Sharpziplib - Fatal编程技术网

C# 无法加载文件或程序集';ICSharpCode.SharpZipLib';或者它的一个依赖项。访问被拒绝

C# 无法加载文件或程序集';ICSharpCode.SharpZipLib';或者它的一个依赖项。访问被拒绝,c#,sharpziplib,C#,Sharpziplib,归档工作在办公室和网站的远程桌面(同事)上进行。我已经测试过了 我正在写一个服务,我也需要它里面的这个。这在我的机器上不起作用,我远程工作并通过VPN连接。登录到此计算机的用户属于该域 现在,在压缩之前,我用一个特殊的用户帐户模拟。如果我不这样做,那么这甚至不会在网站上工作 以下是我得到的例外情况。我怎样才能修好它 System.IO.FileLoadException was caught Message=Could not load file or assembly 'ICSharpCo

归档工作在办公室和网站的远程桌面(同事)上进行。我已经测试过了

我正在写一个服务,我也需要它里面的这个。这在我的机器上不起作用,我远程工作并通过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工作正常。这3个方法在执行关联操作之前首先模拟


谢谢你的调查

通过应用以下方法解决了问题:

  • 将C的所有权授予管理组,并将其深入到文件级,而不是安装程序
  • 为管理员组在C上应用完全控制权限,并深入到文件级别

  • 清理C:\Windows\Microsoft.NET\Framework\…\中的临时文件夹临时ASP.NET文件


    希望这能有所帮助。

    我已经在本地机器上测试了DotNetZipLib,它也导致了相同的错误。这是完美的工作在我的同事的机器就像上面。无法加载文件或程序集“Ionic.Zip,版本=1.9.1.8,区域性=中性,PublicKeyToken=edbe51ad942a3f5c”或其依赖项之一。访问被拒绝。