我将所有nuget包更新到最新版本。无论是在调试还是发布,一切都在本地很好用,但是一旦我发布到azure,我就会在网站主页上看到这个:
[FileLoadException: Could not load file or assembly 'DocumentDB.Spatial.Sql' or one of its dependencies. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)]
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) +457
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +110
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22
System.Reflection.Assembly.Load(String assemblyString) +34
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +48
[ConfigurationErrorsException: Could not load file or assembly 'DocumentDB.Spatial.Sql' or one of its dependencies. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +729
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +247
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +157
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +226
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +73
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +321
System.Web.Compilation.BuildManager.ExecutePreAppStart() +170
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +878
[HttpException (0x80004005): Could not load file or assembly 'DocumentDB.Spatial.Sql' or one of its dependencies. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +124
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +700
这些是安装的Nuget包:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="jQuery" version="3.2.1" targetFramework="net452" />
<package id="Microsoft.AspNet.SignalR" version="2.2.2" targetFramework="net452" />
<package id="Microsoft.AspNet.SignalR.Core" version="2.2.2" targetFramework="net452" />
<package id="Microsoft.AspNet.SignalR.JS" version="2.2.2" targetFramework="net452" />
<package id="Microsoft.AspNet.SignalR.SystemWeb" version="2.2.2" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.Azure.DocumentDB" version="1.18.0" targetFramework="net452" />
<package id="Microsoft.Azure.DocumentDB.ChangeFeedProcessor" version="1.2.0" targetFramework="net452" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.8" targetFramework="net452" />
<package id="Microsoft.Net.Compilers" version="2.4.0" targetFramework="net452" developmentDependency="true" />
<package id="Microsoft.Owin" version="4.0.0-alpha1" targetFramework="net452" />
<package id="Microsoft.Owin.Host.SystemWeb" version="4.0.0-alpha1" targetFramework="net452" />
<package id="Microsoft.Owin.Security" version="4.0.0-alpha1" targetFramework="net452" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
<package id="Owin" version="1.0" targetFramework="net452" />
</packages>
发布构建日志:
1>------ Publish started: Project: redacted, Configuration: Release Any CPU ------
1>Transformed Web.config using C:\Projects\redacted\redacted\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.
1>Auto ConnectionString Transformed obj\Release\TransformWebConfig\transformed\Web.config into obj\Release\CSAutoParameterize\transformed\Web.config.
1>Copying all files to temporary location below for package/publish:
1>obj\Release\Package\PackageTmp.
1>Start Web Deploy Publish the Application/package to https://redacted.scm.azurewebsites.net/msdeploy.axd?site=redacted ...
1>Adding ACLs for path (redacted)
1>Adding ACLs for path (redacted)
1>Updating file (redacted\bin\DocumentDB.Spatial.Sql.dll).
1>Updating file (redacted\bin\redacted.dll).
1>Updating file (redacted\bin\Microsoft.Azure.Documents.Client.dll).
1>Updating file (redacted\bin\Microsoft.Azure.Documents.ServiceInterop.dll).
1>Updating file (redacted\packages.config).
1>Updating file (redacted\Web.config).
1>Adding ACLs for path (redacted)
1>Adding ACLs for path (redacted)
1>Publish Succeeded.
1>Web App was published successfully http://redacted.azurewebsites.net/
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
您可以在构建过程中看到目标DLL被添加到包中。
我无法摆脱这种状态 - 它在开发服务器上,现在我的前端开发人员变得焦虑。
我试过回滚DocumentDB,但没有帮助。这发生在我不情愿地决定更新nuget包之后。
看起来DocumentDB.Spatial.Sql.dll文件甚至不是.net程序集。为什么要这样加载呢?它只是一个原生的64位DLL。
答案 0 :(得分:3)
因此,如果其他人有此问题或类似问题,则发布工具存在错误。我做的解决方法是:
project\bin
和project\obj
目录/site/wwwroot/bin
目录project\bin
目录中的所有文件上传到/site/wwwroot/bin
目录让我的一切都恢复正常。
我在想的是旧版Nuget软件包中存在一些导致冲突的东西。这只是确保在您更新Nuget软件包之后,您的实时网站以一个干净的平板开始。