|
-
Oct 8th, 2012, 06:24 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Error after deployment
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 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.
-
Oct 8th, 2012, 07:12 AM
#2
Re: Error after deployment
I'm not sure why that error message would suggest that cause. The first thing that comes to mind for me is that you're assuming that a query will return some data but it doesn't. It could be any number of things though. The direct cause is that you are trying to access a member of an object via a reference that is Nothing, i.e. the object you're trying to access doesn't exist. The first thing to do is to determine where the exception is being thrown. Once you know where, then you can determine why.
-
Oct 8th, 2012, 08:05 AM
#3
Re: Error after deployment
First thing might be to turn on detailed error reporting
That should give a more detailed description of the problem.
-tg
-
Oct 8th, 2012, 08:05 AM
#4
Thread Starter
Fanatic Member
Re: Error after deployment
The Event viewer tells me the method that it's trying to run:
Code:
try
{
using (my_Connection ctx = new my_Connection())
{
return ctx.Titles.OfType<Title>().ToList();
}
}
From the dev machine this works fine. The table has data in it. The deployed solution currently points to the same database as my dev machine.
-
Oct 8th, 2012, 08:32 AM
#5
Thread Starter
Fanatic Member
Re: Error after deployment
Hi Techgnome,
I'm using IIS6 not 7.
-
Oct 8th, 2012, 09:34 PM
#6
Re: Error after deployment
 Originally Posted by Bill Crawley
The Event viewer tells me the method that it's trying to run:
Code:
try
{
using (my_Connection ctx = new my_Connection())
{
return ctx.Titles.OfType<Title>().ToList();
}
}
From the dev machine this works fine. The table has data in it. The deployed solution currently points to the same database as my dev machine.
If the exception is being thrown on the 'return' line then something before a dot on that line is null, so it should be fairly easy to put a bit of logging code in there to determine what. The other possibility is that something is going wrong inside the 'my_Connection' (that is a horrible name for a class) constructor. Is that just the default constructor or is there some code in there?
-
Oct 9th, 2012, 04:15 AM
#7
Thread Starter
Fanatic Member
Re: Error after deployment
my_Connection has been renamed for this thread to protect the product I'm working on at the moment. It is the Reference to the code generated by the Entity Framework. I've placed some extra error handling in the Catch blocks, but I'm getting no more info.
The error has to be when Entity Framework tries to make the connection to the DB. but I dont know why.
-
Oct 9th, 2012, 04:25 AM
#8
Re: Error after deployment
You should get a stack trace from the exception. That will tell you exactly where exception is thrown.
-
Oct 9th, 2012, 05:32 AM
#9
Thread Starter
Fanatic Member
Re: Error after deployment
This is the stack trace, which is why I think it's a connection issue:
Event Type: Warning
Event Source: ASP.NET 4.0.30319.0
Event Category: Web Event
Event ID: 1309
Date: 08/10/2012
Time: 16:08:47
User: N/A
Computer: WEB-LIVE-7
Description:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 08/10/2012 16:08:46
Event time (UTC): 08/10/2012 15:08:46
Event ID: 1f2a003e2c234a09a3690a0feb51ff04
Event sequence: 10
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/Root/Cover-1-129941825093437500
Trust level: Full
Application Virtual Path: /Cover
Application Path: E:\Webs\testweb\Cover\
Machine name: WEB-LIVE-7
Process information:
Process ID: 2000
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 300
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://197.128.5.14/Cover/AboutYou_PolicyApplicant.aspx
Request path: /Cover/AboutYou_PolicyApplicant.aspx
User host address: 197.128.5.14
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE
Thread information:
Thread ID: 1
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 300
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.
-
Oct 9th, 2012, 05:48 AM
#10
Re: Error after deployment
It says that the exception occurs here:
CoverBL.Common.GetTitles() in C:\My Projects\Customer Websites\Cover\Cover\CoverBL\Common.cs:line 300
What exactly is on line 300 of Common.cs?
-
Oct 9th, 2012, 06:35 AM
#11
Thread Starter
Fanatic Member
Re: Error after deployment
This is the Calling code
Code:
public List<Title> GetTitles()
{
try
{
return _dllayer.GetTitles().ToList();
}
catch (Exception ex)
{
throw new Exception(ex.InnerException.ToString());
}
the _dllayer object has:
Code:
public IList<Title> GetTitles()
{
try
{
using (My_Connection ctx = new MY_Connection())
{
return ctx.Titles.OfType<Title>().ToList();
}
}...
My_Connection is a partial Class generated by the entity Framework of the form:
Code:
public My_Connection() : base("name=MY_Connection", "My_Connection")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
And I can trace the error to this line:
public My_Connection() : base("name=MY_Connection", "My_Connection")
It doesn't get into setting LazyLoading.
-
Oct 9th, 2012, 09:48 AM
#12
Thread Starter
Fanatic Member
Re: Error after deployment
Resolved. was a duff user on the connection string, it had not been set up correctly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|