【问题标题】:Referencing native 64 bit dll in Azure Web Api App在 Azure Web Api App 中引用本机 64 位 dll
【发布时间】:2016-11-04 02:18:00
【问题描述】:

我创建了一个使用本机 64 位 dll 的 Azure Web API 应用程序。我能够在本地运行该服务而没有任何问题。但是,当我尝试在 Azure 上托管它时,出现以下错误。

thread 存在一个关于在 Azure 应用程序中加载本机 DLL 的已知问题。我按照解决方案创建了一个 XDT 脚本,将 bin 文件夹 (D:\home\site\wwwroot\bin) 添加到 PATH。不幸的是,这并没有帮助。

我使用 Azure 门户控制台验证了我的 dll 位于应用程序的 bin 文件夹中。我还在 Kudu 中验证了我的应用程序看到了更新的路径。我确保 Azure 门户内的应用程序设置设置为 64 位。如果我将应用程序设置设置回 32 位模式,它会找到 dll 并引发不正确的格式错误,因此似乎在 Azure 中引用本机 64 位 dll 时存在一些问题。

当我尝试调用我的应用程序时出现以下错误:

Server Error in '/' Application.

    Could not load file or assembly 'My64Bit.DLL' or one of its dependencies. The specified module could not be found. 
    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 'My64Bit.DLL' or one of its dependencies. The specified module could not be found.

    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. 

    Stack Trace: 


    [FileNotFoundException: Could not load file or assembly 'My64Bit.DLL' or one of its dependencies. The specified module could not be found.]
       System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
       System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +234
       System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +108
       System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +25
       System.Reflection.Assembly.Load(String assemblyString) +34
       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +49

    [ConfigurationErrorsException: Could not load file or assembly 'My64Bit.DLL' or one of its dependencies. The specified module could not be found.]
       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +772
       System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +259
       System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +163
       System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +230
       System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +76
       System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +343
       System.Web.Compilation.BuildManager.ExecutePreAppStart() +176
       System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +734

    [HttpException (0x80004005): Could not load file or assembly 'My64Bit.DLL' or one of its dependencies. The specified module could not be found.]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +539
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +125
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +731

【问题讨论】:

    标签: .net azure dll 64-bit azure-web-app-service


    【解决方案1】:

    问题是我将 DLL 编译为 Debug 而不是 Release,这导致它们引用 Azure 中不可用的 VCRUNTIME[...]D 和 MSVCP[...]D 调试 DLL。在 Release 中重新编译 DLL 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-13
      • 2018-05-12
      • 2011-12-21
      • 2011-08-08
      • 2014-07-09
      • 2012-05-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多