locked
Connection works fine in ASP.net but fails in Console app RRS feed

  • Question

  • I have the exact same Oracle connection on the same server with the same userid, password, on the same network.  It works fine in ASP.NET on on Vista, but will give "Object reference not set to an instance of an object." at the Open() method when used in a Console application on the same PC that was running the web server.

     

    Oracle.DataAccess.Client.OracleConnection oc = new Oracle.DataAccess.Client.OracleConnection("....");

    oc.Open();  <---

     

    I know it's Oracle, but the difference in behavior is in the two different Windows environments so I hope someone here also has past experience on this.  I searched and some people thought it's a security permission problem.  I gave full rights to my account running the Console app but to no avail.

     

    Thanks.

     

    PS: I repeat the same thing on a Windows Server and it's the same: fine on ASP.NET, not ok in a Console app.

    Friday, October 24, 2008 3:10 AM

All replies

  • Where is your oc connection variable declared, inside of same method/function where you call Open method of it? I am just thinking if variable did not go out of scope somehow and was disposed.

     

    Friday, October 24, 2008 11:26 AM
  • The two lines of code shown above are as in the real program, ie the two lines are together, one after the other.

     

    I searched, and other people are facing the problem the other way round: works in a Windows Form application but same null reference problem in an ASP.Net application.

    Friday, October 24, 2008 1:34 PM
  • There're some folks also experiencing this issue in the past. Please refere to http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.adonet/topic25922.aspx

    If the error stack is similar like yours, the possible solution would be disable connection pooling specified in the connection string, or try to adjust numbers of connections available and lifetime in pooling service.

     

    Hopefully it helps... 

    Friday, October 24, 2008 5:09 PM
    Answerer
  • Looks like issue related to provider itself. I would recommend checking it with Oracle, since provider comes from them. They might have a fix if it is known issue.

    Friday, October 24, 2008 5:17 PM
  • Is ODP.NET installed on the machine where the console application is running?

     

    Monday, October 27, 2008 12:57 PM
  •  

    Yes, the machine was hosting an ASP.Net application using the same Oracle calls.  It is a single PC used for development and hosting.  I started off by meeting the requirement using ASP.Net web pages.

     

    Now there's a particular piece of data that I need to retrieve at periodic intervals, so I thought a console application would be easier to schedule.  I was expecting a seamless transition from ASP.Net to console as the exact same classes and same methods are used, on the same PC.  But apparently it's not.

     

     

    Tuesday, November 25, 2008 12:03 PM
  • Obvious question, but did you add a reference to the ODP.NET library in your console application project?

    Thursday, November 27, 2008 4:14 AM