无法加载文件或程序集';ICSharpCode.SharpZipLib';或其依赖项之一.访问被拒绝
本文关键字:拒绝 访问 依赖 ICSharpCode 加载 文件 程序集 SharpZipLib | 更新日期: 2024-09-24 12:22:00
归档工作在办公室和网站的远程桌面(同事)上进行。我已经测试过了。
我正在写一个服务,我也需要这个里面。这在我的机器上不起作用,我远程工作,通过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文件。
希望这能有所帮助。