我在Linq To SQL数据上下文中有一个空引用异常,我什至不知道从哪里开始

| 我刚刚在网站上部署了一个用户和角色的asp数据库,但出现此异常 你调用的对象是空的。 说明:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 41:   #endregion
Line 42:    
Line 43:    public UsersAndRolesDataContext() : 
Line 44:                base(global::System.Configuration.ConfigurationManager.ConnectionStrings[\"ConnectionString\"    ].ConnectionString, mappingSource)
Line 45:    {


Source File: d:\\hosting\\7122544\\html\\SSM\\App_Code\\UsersAndRoles.designer.cs    Line: 43

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   UsersAndRolesDataContext..ctor() in d:\\hosting\\7122544\\html\\SSM\\App_Code    \\UsersAndRoles.designer.cs:43
   admin_ManageUsers..ctor() in d:\\hosting\\7122544\\html\\SSM\\admin\\ManageUsers.aspx.cs:11
   ASP.admin_manageusers_aspx..ctor() in c:\\windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files\\ssm\\5b123e8f\\6bb9cf4c\\App_Web_tz5adhff.10.cs:0
   __ASP.FastObjectFactory_app_web_tz5adhff.Create_ASP_admin_manageusers_aspx() in     c:\\windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files\\ssm\\5b123e8f\\6bb9cf4c\\App_Web_tz5adhff.12.cs:0
   System.Web.Compilation.BuildResultCompiledType.CreateInstance() +32
   System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +109
   System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +31
   System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path) +37
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +334
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
    
已邀请:
        您可能缺少配置文件中名为
ConnectionString
的连接字符串,因此
System.Configuration.ConfigurationManager.ConnectionStrings[\"ConnectionString\"    ]
返回null。     
        您可能在Web.config或App.config中缺少连接字符串。确保文件中包含与以下内容相似的内容。
<connectionStrings>
    <add name=\"AdventureWorksEntities\" 
         connectionString=\"metadata=.\\AdventureWorks.csdl|.\\AdventureWorks.ssdl|.\\AdventureWorks.msl;
         provider=System.Data.SqlClient;provider connection string=\'Data Source=localhost;
         Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60;
         multipleactiveresultsets=true\'\" providerName=\"System.Data.EntityClient\" />
</connectionStrings>
    

要回复问题请先登录注册