Results 1 to 12 of 12

Thread: [RESOLVED] Error after deployment

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Resolved [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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    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.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Re: Error after deployment

    Hi Techgnome,

    I'm using IIS6 not 7.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Error after deployment

    Quote Originally Posted by Bill Crawley View Post
    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    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.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Error after deployment

    You should get a stack trace from the exception. That will tell you exactly where exception is thrown.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    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.

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    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.

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    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
  •  



Click Here to Expand Forum to Full Width