I'm using VS2010 with EF5. to an Existing DB. As usual everything works fine on my dev machine. On the server that we are deploying to it is an windows Server 2003 with IIS6. We have installed the Enitity Framework on the server as well as .Net Framework
4.1.
I am Publishing to a File System where someone then picks up the Zip file and installs. I've ensured the connection string in the Web.Config file is ok. The Install seems to work in that we receive no errors. However, when we first go to to load the site
in the browser, an error is produced on the first attempted call by the framework to the DB. Basically it's going to get lookup data to populate a dropdown on the first page. In Dev this all works ok, but in production we receive
Object Reference not set to an instance of an object error. This suggests to me that there is an issue with connecting to the DB by EF but I dont know what to do about it.
Exception message: Object reference not set to an instance of an object.
at CoverBL.Common.GetTitles() in C:\My Projects\Customer Websites\Cover\Cover\CoverBL\Common.cs:line 284
at Cover.AboutYou_PolicyApplicant.Page_Load(Object sender, EventArgs e) in C:\My Projects\Customer Websites\Cover\Cover\Cover\AboutYou_PolicyApplicant.aspx.cs:line 27
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Stack trace: at CoverBL.Common.GetTitles() in C:\My Projects\Customer Websites\Cover\Cover\CoverBL\Common.cs:line 284
at Cover.AboutYou_PolicyApplicant.Page_Load(Object sender, EventArgs e) in C:\My Projects\Customer Websites\Cover\Cover\Cover\AboutYou_PolicyApplicant.aspx.cs:line 27
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Custom event details:
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
public IList<Title> GetTitles()
{
try
{
using (Cover_Connection ctx = new Cover_Connection())
{
return ctx.Titles.OfType<Title>().ToList();
}
}
The Table that this maps to has data. As mentioned from my dev machine all works fine. The deployed solution for now should be connecting to the same database.
private ClearCoverDL.ClearCoverDL _dllayer;
#region constructors
public Common()
{
try
{
_dllayer = new ClearCoverDL.ClearCoverDL();
}.....
As already mentioned. THe code works fine in development. It's only after deployment. The deployed solution is currently using the same DB as my Development machine.
I'm sure the problem is with the connection string between the Entity Framework and the DB but I dont know why. There seems to be a problem wirth making the connection.
billcrawley
Member
341 Points
286 Posts
Error's after deployment
Oct 08, 2012 10:21 AM|LINK
Hi All,
I'm using VS2010 with EF5. to an Existing DB. As usual everything works fine on my dev machine. On the server that we are deploying to it is an windows Server 2003 with IIS6. We have installed the Enitity Framework on the server as well as .Net Framework 4.1.
I am Publishing to a File System where someone then picks up the Zip file and installs. I've ensured the connection string in the Web.Config file is ok. The Install seems to work in that we receive no errors. However, when we first go to to load the site in the browser, an error is produced on the first attempted call by the framework to the DB. Basically it's going to get lookup data to populate a dropdown on the first page. In Dev this all works ok, but in production we receive Object Reference not set to an instance of an object error. This suggests to me that there is an issue with connecting to the DB by EF but I dont know what to do about it.
ignatandrei
All-Star
134973 Points
21638 Posts
Moderator
MVP
Re: Error's after deployment
Oct 08, 2012 11:05 AM|LINK
whole stack trace , please
billcrawley
Member
341 Points
286 Posts
Re: Error's after deployment
Oct 08, 2012 11:23 AM|LINK
Here's the stack trace from event viewer:
Event Type: Warning
Event Source: ASP.NET 4.0.30319.0
Event Category: Web Event
Event ID: 1309
Date: 08/10/2012
Time: 09:35:11
User: N/A
Computer: WEB-LIVE-7
Description:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 08/10/2012 09:35:11
Event time (UTC): 08/10/2012 08:35:11
Event ID: 926398e8c5be497195c9a61368fa5f4f
Event sequence: 7
Event occurrence: 2
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/Root/Cover-1-129941588213906250
Trust level: Full
Application Virtual Path: /Cover
Application Path: E:\Webs\testweb\Cover\
Machine name: WEB-LIVE-7
Process information:
Process ID: 1576
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: NullReferenceException
Exception message: Object reference not set to an instance of an object.
at CoverBL.Common.GetTitles() in C:\My Projects\Customer Websites\Cover\Cover\CoverBL\Common.cs:line 284
at Cover.AboutYou_PolicyApplicant.Page_Load(Object sender, EventArgs e) in C:\My Projects\Customer Websites\Cover\Cover\Cover\AboutYou_PolicyApplicant.aspx.cs:line 27
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Request information:
Request URL: http://192.168.3.12/Cover/AboutYou_PolicyApplicant.aspx
Request path: /Cover/AboutYou_PolicyApplicant.aspx
User host address: 192.168.3.12
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE
Thread information:
Thread ID: 8
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at CoverBL.Common.GetTitles() in C:\My Projects\Customer Websites\Cover\Cover\CoverBL\Common.cs:line 284
at Cover.AboutYou_PolicyApplicant.Page_Load(Object sender, EventArgs e) in C:\My Projects\Customer Websites\Cover\Cover\Cover\AboutYou_PolicyApplicant.aspx.cs:line 27
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Custom event details:
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
ignatandrei
All-Star
134973 Points
21638 Posts
Moderator
MVP
Re: Error's after deployment
Oct 08, 2012 12:21 PM|LINK
What's here?
billcrawley
Member
341 Points
286 Posts
Re: Error's after deployment
Oct 08, 2012 01:36 PM|LINK
line 284 :
and this is actually:
public IList<Title> GetTitles() { try { using (Cover_Connection ctx = new Cover_Connection()) { return ctx.Titles.OfType<Title>().ToList(); } }The Table that this maps to has data. As mentioned from my dev machine all works fine. The deployed solution for now should be connecting to the same database.
kctt
Contributor
5004 Points
948 Posts
Re: Error's after deployment
Oct 09, 2012 04:09 AM|LINK
The error Object Reference not set to an instance of an object error is more like coding error. Some variable you reference does not exist.
ignatandrei
All-Star
134973 Points
21638 Posts
Moderator
MVP
Re: Error's after deployment
Oct 09, 2012 05:57 AM|LINK
and where _dlllayer is initiated?
billcrawley
Member
341 Points
286 Posts
Re: Error's after deployment
Oct 09, 2012 09:08 AM|LINK
_dllayer gets initiated in the constructor
private ClearCoverDL.ClearCoverDL _dllayer; #region constructors public Common() { try { _dllayer = new ClearCoverDL.ClearCoverDL(); }.....As already mentioned. THe code works fine in development. It's only after deployment. The deployed solution is currently using the same DB as my Development machine.
billcrawley
Member
341 Points
286 Posts
Re: Error's after deployment
Oct 09, 2012 09:17 AM|LINK
I'm sure the problem is with the connection string between the Entity Framework and the DB but I dont know why. There seems to be a problem wirth making the connection.
ignatandrei
All-Star
134973 Points
21638 Posts
Moderator
MVP
Re: Error's after deployment
Oct 09, 2012 10:04 AM|LINK
remove the try/catch and wait for exception