如何解决无法加载或找到程序集Microsoft.Azure.cosmos.table
我有一个Windows窗体应用程序WinFormsProj
,该应用程序引用了名为ModelsProj
的类库项目。ModelsProj
依赖于Microsoft.Azure.Cosmos.Table
1.0.7.0版。
在运行时,WinFormsProj
到达此代码时,引发一个FileNotFoundException
并说could not load or find assemble
Microsoft.Azure.Cosmos.Table`:
var entityTypes = typeof(EntityBase).Assembly.GetExportedTypes()
.Where(t => t.GetInterface(typeof(IDto).FullName) == null
&& t.GetInterface(typeof(IEntity).FullName) != null && !t.IsAbstract);
EntityBase
是我所有模型实体的基本类型,位于ModelProj
中。
我可以通过在Microsoft.Azure.Cosmos.Table
中添加对WinFormsProj
的引用来解决该异常。
但是,我希望程序不执行此操作!
我的问题是:为什么Microsoft.Azure.Cosmos.Table
的dll无法复制到输出?生成过程不是应该将所有需要的dll放在输出目录中吗?
我发现here的常见原因是,一个项目及其依赖项依赖于同一软件包的不同版本。这不是我的情况,WinFormsProj
本身不必引用任何版本的Microsoft.Azure.Cosmos.Table
!
更多信息:
我已经使用fuslogvw.exe
检查发生了什么,这是它的日志:
*** Assembly Binder Log Entry (8/12/2020 @ 10:25:22 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable H:\melkradar-git\melkradar\src\MelkRadar\Mgmt\MelkRadar.Mgmt.Win\bin\Debug\MelkRadar.Mgmt.Win.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Azure.Cosmos.Table,Version=1.0.7.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///H:/melkradar-git/melkradar/src/MelkRadar/Mgmt/MelkRadar.Mgmt.Win/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MelkRadar.Mgmt.Win.exe
Calling assembly : MelkRadar.Core.Model,Version=1.0.0.0,PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: H:\melkradar-git\melkradar\src\MelkRadar\Mgmt\MelkRadar.Mgmt.Win\bin\Debug\MelkRadar.Mgmt.Win.exe.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: Microsoft.Azure.Cosmos.Table,PublicKeyToken=31bf3856ad364e35
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///H:/melkradar-git/melkradar/src/MelkRadar/Mgmt/MelkRadar.Mgmt.Win/bin/Debug/Microsoft.Azure.Cosmos.Table.DLL.
LOG: Attempting download of new URL file:///H:/melkradar-git/melkradar/src/MelkRadar/Mgmt/MelkRadar.Mgmt.Win/bin/Debug/Microsoft.Azure.Cosmos.Table/Microsoft.Azure.Cosmos.Table.DLL.
LOG: Attempting download of new URL file:///H:/melkradar-git/melkradar/src/MelkRadar/Mgmt/MelkRadar.Mgmt.Win/bin/Debug/Microsoft.Azure.Cosmos.Table.EXE.
LOG: Attempting download of new URL file://
顺便说一句,在类似的问题中,我曾尝试清理解决方案,重新启动VS,重建并重试。这没用。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。