我創建了一個使用原生64位dll的Azure Web API應用程序。我能夠在沒有任何問題的情況下在本地運行服務。但是,當我嘗試在Azure上託管它時,出現以下錯誤。在Azure Web Api App中引用原生64位dll
有一個thread與一個已知的問題有關在Azure應用程序內加載本機DLL。我按照解決方案創建了一個XDT腳本來將bin文件夾(D:\ home \ site \ wwwroot \ bin)添加到PATH中。不幸的是,這並沒有幫助。
我使用Azure Portal Console驗證了我的dll位於應用程序的bin文件夾中。我也在Kudu驗證我的應用程序看到更新的路徑。我確保Azure Portal內的應用程序設置設置爲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