我从我以前的一个NopCommerce网站复制了源代码,复制并重命名了Azure上的数据库,并更新了settings.txt文件以指向新的数据库。唯一的其他更改是对css的更改。
当我在本地主机上运行新站点时,它运行得非常完美,没有任何问题,但是,当我从VS发布到Azure,然后浏览到URL时,我会在'/‘Application中得到一个错误-服务器错误。对于我的生活,我无法弄清楚这个问题,我想知道是否还有其他人经历过这件事。
我用的是Nop 3.5
我的直觉告诉我,我的连接字符串有问题,然而,为什么要在本地主机上工作,而不是在发布时?
下面是异常详细信息和堆栈跟踪
提前感谢您的帮助
'/‘应用程序中的服务器错误。参数'nameOrConnectionString‘不能为空,也不能只包含空白。描述:在执行当前web请求时发生了未处理的异常。请查看堆栈跟踪以获得有关错误的更多信息,以及它起源于代码的位置。
异常详细信息: System.ArgumentException:参数'nameOrConnectionString‘不能为空、空或只包含空白。
源错误:
生成此未处理异常的源代码只能在调试模式下编译时显示。要启用此功能,请执行以下步骤之一,然后请求URL:
或者:
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版本信息:微软.NET框架版本: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;
}
}
}发布于 2015-04-23 08:02:30
在NopCommerce中,连接字符串是在一个名为Settings.txt的文件中设置的,该文件位于Presnetation\Nop.Web\App_Data文件夹中。但是,它不是解决方案的一部分,因此不会被部署。你可以:
Nop.Web项目并进行部署。发布于 2015-05-13 00:24:56
好的,这是我发现的。
如果DNS_PROBE_FINISHED_NXDOMAIN错误100%正确,则settings.txt在App_Data中的语句。问题是,URL提供的http://yourwebsite.azurewebsites.net/不起作用,直到自定义域连接起来并用于导航到该站点按预期运行的网站。
https://stackoverflow.com/questions/29743095
复制相似问题