c# - 无法加载文件或程序集 'XXX' 或其依赖项之一。该系统找不到指定的文件

标签 c# sql-server entity-framework azure

我有两个项目(Crestfine 和 CrestfineWebapp)已部署在 Azure Web 应用服务上。但是,Web 应用程序因错误而无法运行

   Could not load file or assembly 'crestfine' or one of its dependencies. The system cannot find the file specified. 

这里的 Crestfine 是运行良好的 Web API。 CrestfineWebapp 抛出此错误

装配加载跟踪:

   WRN: Assembly binding logging is turned OFF.
   To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
   Note: There is some performance penalty associated with assembly bind failure logging.
   To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]

堆栈跟踪:

[FileNotFoundException: Could not load file or assembly 'crestfine' or one of its dependencies. The system cannot find the file specified.]
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +95
   System.Type.GetType(String typeName, Boolean throwOnError) +63
   System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(Type requiredContextType, String contextTypeName, String initializerTypeName, Boolean isDisabled, Func`1 initializerArgs, Func`3 exceptionMessage) +46

[InvalidOperationException: Failed to set database initializer of type 'System.Data.Entity.MigrateDatabaseToLatestVersion`2[[crestfine.DAL.CrestfineContext, crestfine], [crestfine.Migrations.Configuration, crestfine]], EntityFramework, PublicKeyToken=b77a5c561934e089' for DbContext type 'crestfine.DAL.CrestfineContext, crestfine' specified in the application configuration. See inner exception for details.]
System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(Type requiredContextType, String contextTypeName, String initializerTypeName, Boolean isDisabled, Func`1 initializerArgs, Func`3 exceptionMessage) +326
 System.Data.Entity.Internal.<>c__DisplayClass6.<TryGetInitializerFromEntityFrameworkSection>b__1(ContextElement e) +276
 System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +223
 System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +115
 System.Data.Entity.Internal.InitializerConfig.TryGetInitializer(Type contextType) +23
 System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetServiceFactory(Type type, String name) +534
 System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +84
System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetService(Type type, Object key) +187
 System.Linq.WhereSelectArrayIterator`2.MoveNext() +75
 System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +115
System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver`2.GetService(Type type, Object key) +41
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +159
  System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +174
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +269
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +38
  System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +77
  System.Data.Entity.Internal.Linq.InternalSet`1.GetAsyncEnumerator() +21
System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.ForEachAsync(IDbAsyncEnumerable`1 source, Action`1 action, CancellationToken cancellationToken) +69
System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.ToListAsync(IDbAsyncEnumerable`1 source, CancellationToken cancellationToken) +315

我已将 Azure 平台架构设置为 64 位 enter image description here

在本地,它们都可以通过以下设置正常运行 enter image description here

enter image description here

最佳答案

我的评论部分已发送解决方案,很容易解决 Blog

我继续添加了对 CrestfineWebApp 的 CrestFine(Web api)引用。此外,我将平台目标更改为:

enter image description here

来自

AnyCPU

关于c# - 无法加载文件或程序集 'XXX' 或其依赖项之一。该系统找不到指定的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49319995/

相关文章:

c# - 为什么我从 C# 应用程序调用 VB6 ActiveX DLL 失败并返回 "No such interface supported"?

c# - 如何使用 Twitterizer 在 C# 中获取 Twitter 用户时间线

c# - 将多项选择元素从 XML 序列化为 C#

c# - C# 中的 XML 字段替换

sql-server - 动态 SQL 查询未将数据返回到 SQL 表

c# - Entity Framework 6、存储库模式和工作单元

c# - 在 C# 中使用 Entity Framework、Mysql 和 LINQ to SQL 提交和回滚事务

c# - 如何使用 C# 将 CSV 文件上传到 sql server 表?

c# - 批量复制提交行没有错误

c# - 使用 EF6 连接到 DB2