我的System.NullReferenceException
Web 应用程序出现异常:
[NullReferenceException: Object reference not set to an instance of an object.]
Home..ctor() in D:\Hosting\9651310\html\Home.aspx.vb:6
ASP.home_aspx..ctor() in D:\Hosting\9651310\html\Home.aspx.vb:912304
__ASP.FastObjectFactory_app_web_2ocmh1tt.Create_ASP_home_aspx() +47
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
这是引发异常的行:
Dim con As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("Connection").ToString())
我的 web.config 文件的连接字符串部分如下所示:
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
</connectionStrings>