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

时间:2018-03-16 11:44:09

标签: 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

1 个答案:

答案 0 :(得分:2)

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

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

enter image description here

来自

public void SyncNow(View view) {
    final DatabaseReference root = FirebaseDatabase.getInstance().getReference();

    for (i=0; i<storeContacts.size(); i++){
        UserContact contact = storeContacts.get(i);
        final String number = contact.getContactNumber();
        Query query = root.child("contactList").orderByChild("contactNumber").equalTo(number);
        query.addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                if (dataSnapshot.exists()){
                    //do nothing
                }else {
                    String key = root.push().getKey();
                    root.child("ContactList").child(key).setValue(contact);
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
    }

}