无法加载或找到程序集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 (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...