【问题标题】:Windows Azure Error - Could not load file or assembly MFCMIFC80Windows Azure 错误 - 无法加载文件或程序集 MFCMIFC80
【发布时间】:2015-09-17 08:39:28
【问题描述】:

我创建了一个 Angular/WebAPI/MongoDb 项目并使用 StructureMap 进行依赖注入,并将它发布到一个私人 BitBucket 帐户。

我已经创建了一个 Azure Webapp,并将其设置为在我提交对我的 BitBucket 存储库的更改时自动部署。

当我在本地(从 Visual Studio)运行它时,我的主页是: http://localhost:37071/index.html#/

API 调用http://localhost:37071/api/stock?stkSymbol=ORCL 成功。

然而,当它被部署时,我的页面在:http://myAzureProject.azurewebsites.net/index.html#/成功加载

但是,所有 API 调用:http://myAzureProject.azurewebsites.net/api/stock?stkSymbol=ORCL

失败并显示此错误消息:

Server Error in '/' Application.

Could not load file or assembly 'MFCMIFC80, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'MFCMIFC80, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'MFCMIFC80, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' could not be loaded.


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].

Stack Trace: 


[FileNotFoundException: Could not load file or assembly 'MFCMIFC80, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.]
   System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) +0
   System.Reflection.RuntimeAssembly.GetExportedTypes() +21
   StructureMap.Graph.TypePool.<.ctor>b__0(Assembly assembly) +10
   StructureMap.Util.LightweightCache`2.get_Item(TKey key) +65
   StructureMap.Graph.<>c__DisplayClass3.<For>b__2(Assembly x) +37
   System.Linq.<SelectManyIterator>d__14`2.MoveNext() +232
   StructureMap.StringExtensions.Each(IEnumerable`1 enumerable, Action`1 action) +140
   StructureMap.Graph.AssemblyScanner.ScanForTypes(TypePool types, PluginGraph pluginGraph) +128
   StructureMap.<>c__DisplayClass2.<RunConfigurations>b__1(AssemblyScanner x) +21
   StructureMap.StringExtensions.Each(IEnumerable`1 enumerable, Action`1 action) +131
   StructureMap.PluginGraphBuilder.RunConfigurations() +143
   StructureMap.PluginGraphBuilder.Build() +13
   StructureMap.PipelineGraph.For(Action`1 action) +49
   myAzureProject.DependencyResolution.IoC.Initialize() +82
   myAzureProject.App_Start.StructuremapMvc.Start() +10

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +192
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +155
   WebActivatorEx.BaseActivationMethodAttribute.InvokeMethod() +57
   WebActivatorEx.ActivationManager.RunActivationMethods(Boolean designerMode) +350
   WebActivatorEx.ActivationManager.Run() +78

[InvalidOperationException: The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +547
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521

[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930568
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.36215

我不熟悉 MFCMIFC80 是什么,或者我需要做什么才能将其部署到我的 Azure Web 应用程序。

任何帮助将不胜感激。

谢谢!

【问题讨论】:

    标签: angularjs mongodb azure asp.net-web-api structuremap


    【解决方案1】:

    MFCMIFC80.dll 是一个 MFC 库 (https://en.wikipedia.org/wiki/Microsoft_Foundation_Class_Library)。这很可能是您的 MongoDB 驱动程序的要求。因为我不记得对使用 AngularJS 的常规 Web API 的 MFC 有任何依赖。

    您不能在 Azure Web 应用程序(以前的网站)上部署 MFC。

    寻找不依赖于 MFC 的替代 MongoDB 驱动程序。

    此错误的另一个原因可能是在您的项目中引用了 .NET 2.0 程序集,而您的主项目以 .NET 4.0 为目标。 MongoDB 驱动程序确实可能是这种情况(它可能只针对 .NET 2.0 编译,并且会导致问题)。

    因此,请检查所有引用(包括 StructureMap 和 MongoDB 驱动程序)以确保所有引用的程序集都针对 .NET 4.0 而不是 .NET 2.0。

    请注意,尽管 .NET 4.0 实际上在 .NET 2.0 运行时环境中运行,但在从 .NET 4.0 目标项目中引用 .NET 2.0 程序集时仍可能存在问题。

    【讨论】:

    • 嗯....我会调查一下,看看这是否是问题所在。这是一个在 Visual Studio 2012 中构建的全新项目。所有库都是直接从 Nuget 中提取的新包。我正在使用 .net 的官方 MongoDb 驱动程序。
    • 我刚刚检查了解决方案中的每个项目,每个项目都针对 .NET Framework 4.5。有什么方法可以找出引用该库的内容吗?
    • 我建议从一一删除引用的包开始。第一个是 MongoDB 驱动程序。如果它确实解决了问题,那么您将知道根本原因并开始围绕它进行研究。
    • 我删除了 Mongo,但没有用。我还删除了 Humanizer,但也没有用。
    • 我在我的解决方案文件夹中搜索了 MFCMIFC80.dll,但找不到任何东西。我还在本地发布了我的项目,并在该文件夹中搜索了 MFCMIFC80.dll,但它也不存在。
    【解决方案2】:

    终于想通了。在我的解决方案中,我有一行告诉结构映射从路径扫描程序集。

    scan.AssembliesFromPath(Environment.CurrentDirectory);
    

    删除此行即可解决问题。

    【讨论】:

      猜你喜欢
      • 2014-10-22
      • 2010-10-07
      • 2023-03-05
      • 2013-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-23
      相关资源
      最近更新 更多