如何修复“ConnectionString 属性尚未初始化”在 nopCommerce 中

发布于 2024-09-17 12:31:47 字数 3169 浏览 3 评论 0原文

我正在尝试将 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(Nullable1 forMergeOption) +46 System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable.GetEnumerator() +44 System.Linq.Enumerable.ToDictionary(IEnumerable1 源,Func2 keySelector,Func2 elementSelector,IEqualityComparer1 比较器)+151 System.Linq.Enumerable.ToDictionary(IEnumerable1 源,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(Nullable1 forMergeOption) +46
System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +44
System.Linq.Enumerable.ToDictionary(IEnumerable
1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) +151
System.Linq.Enumerable.ToDictionary(IEnumerable
1 source, Func`2 keySelector) +90
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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

只是在用心讲痛 2024-09-24 12:31:47

您需要有一个有效的连接字符串。

通过数据库安装阶段后(当您填写数据库设置时),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 the Presentation\Nop.Web\App_Data\ named Settings.txt, update it if you need and run the application again.

北笙凉宸 2024-09-24 12:31:47

您需要在 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 in Application_Start.

眸中客 2024-09-24 12:31:47

连接字符串不保存在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文