' /'中的服务器错误发布到Azure时的应用程序

时间:2015-04-20 08:47:33

标签: asp.net-mvc azure nopcommerce nop

我复制了以前的一个NopCommerce网站的源代码,在Azure上复制并重命名了数据库,并更新了settings.txt文件以指向新数据库。唯一的其他变化是css。

当我在localhost上运行新站点时,它完美无缺,但是当我从VS发布到Azure然后浏览到URL时出现错误 - 服务器错误在' /'应用。对于我的生活,我无法想象这一点,并想知道是否有其他人经历过这一点。

我正在使用Nop 3.5

我的直觉告诉我,我的连接字符串有问题,但是,为什么会在localhost上工作但在发布时却没有?...

以下是异常详细信息和堆栈跟踪

提前感谢您提供任何帮助

' /'中的服务器错误应用。 参数&name; nameOrConnectionString'不能为null,为空或仅包含空格。 描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中的起源位置的更多信息。

异常详细信息:System.ArgumentException:参数' nameOrConnectionString'不能为空,空或仅包含空格。

来源错误:

生成此未处理异常的源代码只能在调试模式下编译时显示。要启用此功能,请按照以下步骤之一,然后请求网址:

  1. 添加" Debug = true"生成错误的文件顶部的指令。例如:

  2. 或:

    2)将以下部分添加到应用程序的配置文件中:

    <configuration>
       <system.web>
           <compilation debug="true"/>
       </system.web>
    </configuration>
    

    请注意,第二种技术将导致给定应用程序中的所有文件都以调试模式进行编译。第一种技术只会导致在调试模式下编译该特定文件。

    重要:在调试模式下运行应用程序会产生内存/性能开销。在部署到生产方案之前,应确保应用程序已禁用调试。

    堆栈追踪:

    [ArgumentException: The argument 'nameOrConnectionString' cannot be null, empty or contain only white space.]
       System.Data.Entity.Utilities.Check.NotEmpty(String value, String parameterName) +61
       System.Data.Entity.DbContext..ctor(String nameOrConnectionString) +22
       Nop.Web.Framework.<>c__DisplayClass15.<Register>b__9(IComponentContext c) +42
       Autofac.<>c__DisplayClass10`1.<Register>b__f(IComponentContext c, IEnumerable`1 p) +10
       Autofac.Builder.<>c__DisplayClass1`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p) +14
       Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +32
       Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
       Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
       Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
       Autofac.Core.Resolving.InstanceLookup.Execute() +132
       Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
       Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
       Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0() +31
       Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +94
       Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +185
       Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
       Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
       Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
       Autofac.Core.Resolving.InstanceLookup.Execute() +132
       Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
       Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
       Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0() +31
       Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +94
       Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +185
       Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
       Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
       Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
       Autofac.Core.Resolving.InstanceLookup.Execute() +132
       Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
       Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
       Autofac.Core.Activators.Reflection.<>c__DisplayClass2.<CanSupplyValue>b__0() +31
       Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate() +94
       Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +185
       Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
       Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
       Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
       Autofac.Core.Resolving.InstanceLookup.Execute() +132
       Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
       Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +24
       Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +74
       Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) +54
       Autofac.ResolutionExtensions.Resolve(IComponentContext context, IEnumerable`1 parameters) +118
       Nop.Web.Framework.SettingsSource.<BuildRegistration>b__5(IComponentContext c, IEnumerable`1 p) +35
       Autofac.Builder.<>c__DisplayClass1`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p) +14
       Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) +32
       Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) +48
       Autofac.Core.Resolving.InstanceLookup.<Execute>b__0() +8
       Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) +120
       Autofac.Core.Resolving.InstanceLookup.Execute() +132
       Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) +133
       Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +44
    
    [DependencyResolutionException: An exception was thrown while executing a resolve operation. See the InnerException for details. ---> The argument 'nameOrConnectionString' cannot be null, empty or contain only white space. (See inner exception for details.)]
       Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) +112
       Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +108
       Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance) +74
       Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) +54
       Autofac.ResolutionExtensions.Resolve(IComponentContext context, IEnumerable`1 parameters) +118
       Autofac.ResolutionExtensions.Resolve(IComponentContext context) +46
       Nop.Core.Infrastructure.DependencyManagement.ContainerManager.Resolve(String key, ILifetimeScope scope) +89
       Nop.Core.Infrastructure.NopEngine.Resolve() +55
       FoxNetSoft.Plugin.Misc.RFQ2.UpdateStartUpTask.Execute() +34
       Nop.Core.Infrastructure.NopEngine.RunStartupTasks() +477
       Nop.Core.Infrastructure.NopEngine.Initialize(NopConfig config) +36
       Nop.Core.Infrastructure.EngineContext.Initialize(Boolean forceRecreate) +92
       Nop.Web.MvcApplication.Application_Start() +30
    
    [HttpException (0x80004005): An exception was thrown while executing a resolve operation. See the InnerException for details. ---> The argument 'nameOrConnectionString' cannot be null, empty or contain only white space. (See inner exception for details.)]
       System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9916673
       System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
       System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
       System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
       System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
    
    [HttpException (0x80004005): An exception was thrown while executing a resolve operation. See the InnerException for details. ---> The argument 'nameOrConnectionString' cannot be null, empty or contain only white space. (See inner exception for details.)]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930568
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
    

    版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.36215

    更新

    从我评论中的链接我想我需要在下面定义连接字符串?来自NopObjectContext.cs

    namespace Nop.Data
    {
        /// <summary>
        /// Object context
        /// </summary>
        public class NopObjectContext : DbContext, IDbContext
        {
            #region Ctor
    
            public NopObjectContext(string nameOrConnectionString)
                : base(nameOrConnectionString)
            {
                //((IObjectContextAdapter) this).ObjectContext.ContextOptions.LazyLoadingEnabled = true;
            }
         }
    }
    

2 个答案:

答案 0 :(得分:0)

在NopCommerce中,连接字符串设置在名为Settings.txt的文件中,该文件位于Presnetation\Nop.Web\App_Data文件夹中。但是,它不是解决方案的一部分,因此不会部署。你可以:

  1. 手动发布该文件。
  2. 将文件添加到Nop.Web项目并进行部署。

答案 1 :(得分:0)

好的,这就是我找到的。

如果100%正确,如果在App_Data中存在settings.txt,则DNS_PROBE_FINISHED_NXDOMAIN错误的声明。问题是,Azure提供的URL https://jsfiddle.net/uxdney3L/3/不起作用,直到自定义域被连接并用于导航到网站按预期运行的网站。