![](/img/trans.png)
[英]Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XX' or one of its dependencies
[英]Could not load file or assembly 'XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies
我一直在嘗試調試此錯誤:
System.IO.FileNotFoundException:無法加載文件或程序集'ClassLibrary1,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'或其依賴項之一。 該系統找不到指定的文件。 文件名:'ClassLibrary1,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'
我看到了很多解決方案,並嘗試了所有解決方案。
我正在查看Fusion Viewer,並且收到以下消息:
日志:此綁定在默認的加載上下文中啟動。 日志:使用應用程序配置文件:I:\\ Projects \\ ACE Explorer \\ AceV_1Explorer \\ AceExplorer \\ AceExplorer \\ bin \\ Debug \\ AceExplorer.exe.config日志:使用主機配置文件:日志:使用來自C:\\ Windows \\ Microsoft的計算機配置文件.NET \\ Framework64 \\ v4.0.30319 \\ config \\ machine.config。 日志:政策后參考:ClassLibrary1,版本= 1.0.0.0,區域性=中性,PublicKeyToken =空日志:GAC查找失敗。 日志:嘗試下載新的URL文件:/// I:/ Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1.DLL。 日志:嘗試下載新的URL文件:/// I:/ Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1 / ClassLibrary1.DLL。 日志:嘗試下載新的URL文件:/// I:/ Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1.EXE。 日志:嘗試下載新的URL文件:/// I:/ Projects / ACE Explorer / AceV_1Explorer / AceExplorer / AceExplorer / bin / Debug / ClassLibrary1 / ClassLibrary1.EXE。 日志:所有探測URL嘗試失敗。
我在目錄中看到該文件,並且使用x86的目標框架均為4.0
找出損壞的任何想法
抱歉,已更新 。 在日志中是PublicKeyToken = null。 我正在嘗試一切。
UPDATE我在主程序中添加了一些代碼,這些代碼將使用ResolveEventHandler解析程序集。 起初它沒有用。 但是,當我讓程序在程序開始時加載那些外部程序集(LoadReferences())時,它確實可以工作。 奇怪的是,當我在開始的LoadReferences()中加載它們,然后當該方法輸入對觸發CurrentDomain_AssemblyResolve的自定義程序集的引用時,該路徑是完全相同的。 空白路徑解析為Assemblypath。 如您所見,在LoadReferences()中,我添加了EntityFramework,即使我使用的是Nuget,它也會引起相同的問題。
在Main()中,我添加了:
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
LoadReferences();
private static void LoadReferences()
{
Assembly objExecutingAssemblies;
objExecutingAssemblies = Assembly.GetExecutingAssembly();
AssemblyName[] arrReferencedAssmbNames = objExecutingAssemblies.GetReferencedAssemblies();
Assembly asm;
foreach (AssemblyName strAssmbName in arrReferencedAssmbNames)
{
if (strAssmbName.FullName.ToLower().Contains("[company].") || strAssmbName.FullName.ToLower().Contains("entityframework"))
asm = Assembly.LoadFrom(Path.Combine("", strAssmbName.FullName.Substring(0, strAssmbName.FullName.IndexOf(","))+ ".dll"));
}
// these were also posing an issue
asm = Assembly.LoadFrom(Path.Combine("", "EntityFramework.dll"));
asm = Assembly.LoadFrom(Path.Combine("", "EntityFramework.SqlServer.dll"));
}
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
string assembliesDir = "";
try
{
string dll = (args.Name.IndexOf(",") < 0 ? args.Name + ".dll" : args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll");
Assembly asm = Assembly.LoadFrom(Path.Combine(assembliesDir, dll));
return asm;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return null;
}
也。 不知道這是否有所作為,但這是一次完全信任的單擊。
此外,我們的台式機已被鎖定。
此外,所有項目的平台都設置為x86。
文件:/// I:/ Projects / ACE Explorer /.../ bin / Debug / ClassLibrary1.DLL。
這個問題需要心理調試。 要求Fusion解析I:
驅動器上的路徑。 這通常是映射到文件服務器上共享的驅動器號。 經常這樣麻煩。 考慮到對安全性的過分關注,ACE易於成為Access Control Entry的縮寫。 這使得程序很可能使用模擬來“探索”訪問權限。 這使得Fusion可能無法弄清楚I:
驅動器可能指的是什么,驅動器映射是針對每個用戶的設置。
在程序早期可以正常工作,因為它仍使用默認的用戶令牌運行。 程序一旦部署,就可以正常工作,因為它現在的位置穩定,不再依賴於驅動器號映射。
我不確定要提出什么建議,我是《日內瓦程序員權利公約》的特許成員。 這就要求程序員可以在本地驅動器上創建和測試程序,並安裝所需的調試工具,以查明其程序為何不起作用。 這是您的IT員工需要解決的問題。 如果這樣可以讓您控制自己的開發機器,那么您將遙遙領先。 考慮到Google對於“映射驅動器上的.net調試項目”查詢返回的命中情況,可能會產生結果。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.