0

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

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

感谢您调查它!

4

2 回答 2

1

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

  1. 将 C 的所有权授予管理组并将其深入到文件级别而不是安装程序。
  2. 在 C 上为管理员组应用完全控制权限并将其向下钻取到文件级别
于 2012-08-07T05:28:15.853 回答
1

清理 C:\Windows\Microsoft.NET\Framework\...\Temporary ASP.NET Files 中的临时文件夹。

希望这能有所帮助。

于 2013-12-16T16:29:16.950 回答