如何修复“ConnectionString 属性尚未初始化”在 nopCommerce 中
我正在尝试将 nopCommerce 集成到第三方系统中,但当我尝试访问任何 nopCommerce 页面时遇到问题。因为我正在与第三方系统集成,所以我必须合并 web.configs 并复制所有文件。我也有一个独立安装的 nopCommerce,并且运行良好。
任何帮助将不胜感激。
我收到的错误如下:
ConnectionString 属性尚未初始化。 描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。
异常详细信息:System.InvalidOperationException:ConnectionString 属性尚未初始化。
源错误:
当前 Web 请求执行期间生成未处理的异常。有关异常来源和位置的信息可以使用下面的异常堆栈跟踪来识别。
堆栈跟踪:
[InvalidOperationException:ConnectionString 属性尚未初始化。] System.Data.SqlClient.SqlConnection.PermissionDemand() +5038498 System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection 外连接)+20 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection externalConnection,DbConnectionFactory 连接工厂)+126 System.Data.SqlClient.SqlConnection.Open() +125 System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptsOperation, Boolean& closeStoreConnectionOnFailure) +52
[EntityException: 底层提供程序在打开时失败。] System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(布尔 openCondition,DbConnection storeConnectionToOpen,DbConnection OriginalConnection,字符串ExceptionCode,字符串尝试操作,布尔& closeStoreConnectionOnFailure)+161 System.Data.EntityClient.EntityConnection.Open() +98 System.Data.Objects.ObjectContext.EnsureConnection() +81 System.Data.Objects.ObjectQuery1.GetResults(Nullable
1 forMergeOption) +46 System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable
1 源,Func2 keySelector,Func
2 elementSelector,IEqualityComparer1 比较器)+151 System.Linq.Enumerable.ToDictionary(IEnumerable
1 源,Func`2 keySelector) +90 NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetAllSettings() +542 NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetSettingByName(字符串名称)+121 NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetSettingValue(字符串名称)+49 NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetSettingValueBoolean(字符串名称,布尔默认值)+54 NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetSettingValueBoolean(字符串名称)+41 NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.CustomerManager.get_UsernamesEnabled() +45 NopSolutions.NopCommerce.Web.Administration.LoginPage.ApplyLocalization() +108 NopSolutions.NopCommerce.Web.Administration.LoginPage.Page_Load(对象发送者,EventArgs e)+40 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,对象o,对象t,EventArgs e)+14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(对象发送者,EventArgs e)+35 System.Web.UI.Control.OnLoad(EventArgs e)+91 NopSolutions.NopCommerce.Web.BaseNopAdministrationPage.OnLoad(EventArgs e) +44 System.Web.UI.Control.LoadRecursive() +74 System.Web.UI.Page.ProcessRequestMain(布尔值includeStagesBeforeAsyncPoint,布尔值includeStagesAfterAsyncPoint)+2207
I'm trying to integrate nopCommerce into a third party system but am hitting a problem when I try to access any nopCommerce pages. Because I'm integrating with a third party system I've had to merge web.configs and copy all files over. I have a standalone install of nopCommerce aswell and that is running fine.
Any help would be greatly appreciated.
The error I am getting is as follows:
The ConnectionString property has not been initialized.
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.InvalidOperationException: The ConnectionString property has not been initialized.
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:
[InvalidOperationException: The ConnectionString property has not been initialized.]
System.Data.SqlClient.SqlConnection.PermissionDemand() +5038498
System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection) +20
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
System.Data.SqlClient.SqlConnection.Open() +125
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +52
[EntityException: The underlying provider failed on Open.]
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +161
System.Data.EntityClient.EntityConnection.Open() +98
System.Data.Objects.ObjectContext.EnsureConnection() +81
System.Data.Objects.ObjectQuery1.GetResults(Nullable
1 forMergeOption) +46
System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +44
1 source, Func
System.Linq.Enumerable.ToDictionary(IEnumerable2 keySelector, Func
2 elementSelector, IEqualityComparer1 comparer) +151
1 source, Func`2 keySelector) +90
System.Linq.Enumerable.ToDictionary(IEnumerable
NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetAllSettings() +542
NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetSettingByName(String name) +121
NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetSettingValue(String name) +49
NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetSettingValueBoolean(String name, Boolean defaultValue) +54
NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetSettingValueBoolean(String name) +41
NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.CustomerManager.get_UsernamesEnabled() +45
NopSolutions.NopCommerce.Web.Administration.LoginPage.ApplyLocalization() +108
NopSolutions.NopCommerce.Web.Administration.LoginPage.Page_Load(Object sender, EventArgs e) +40
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
NopSolutions.NopCommerce.Web.BaseNopAdministrationPage.OnLoad(EventArgs e) +44
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要有一个有效的连接字符串。
通过数据库安装阶段后(当您填写数据库设置时),nop commerce 会将数据库信息保存在不在项目内的文件中,您可以在
App_Data 文件夹
中找到它Presentation\Nop.Web\App_Data\
名为Settings.txt
,如果需要请更新它并再次运行应用程序。You need to have a valid connection string.
After you pass the database installation phase (when you fill in the database settings) nop commerce is keeping the database information in a file that is not within the project, you can find it within the
App_Data folder
in thePresentation\Nop.Web\App_Data\
namedSettings.txt
, update it if you need and run the application again.您需要在 web.config 中拥有 NopCommerce 数据库的有效连接字符串,并且需要确保它能够被读取。
在 global.asax 中的
Application_Start
中,NopCommerce 读取连接字符串并将其注入业务逻辑 DLL 中。如果没有发生这种情况,数据访问层(在业务逻辑 DLL 中)将无法打开连接,并且您将收到刚刚发布的错误。我建议检查 web.config 和 global.asax;如果两者看起来都不错,请在Application_Start
中放置一个断点。You need to have a valid connection string for the NopCommerce database in web.config, and you need to ensure that it gets read.
At
Application_Start
in global.asax NopCommerce reads in the connection string and injects it into the business logic DLL. If that doesn't happen, the data access layer (in the business logic DLL) won't be able to open a connection and you'll get the error you just posted. I suggest check web.config and global.asax; if both look good put a breakpoint inApplication_Start
.连接字符串不保存在 nopcommerce 的 web.config 文件中...它位于 ConnectionStrings.config 文件中。您可能需要检查该文件,如果不存在则将其复制过来,或者如果文件存在而字符串不存在,则将连接字符串放入其中。
The connection string is not held in the web.config file in nopcommerce... it is in the ConnectionStrings.config file. You might want to check for that file and copy it over if it is not there or put your connection string in there if the file is there and the string is not.