Can't call objects in my business layer from a console application in my solution.

  • Thread starter Thread starter NWeller
  • Start date Start date
N

NWeller

Mike said:
I am getting a error that should not be happening when I instantiate an
object from my business layer in a console application within my solution.

I get an "object reference not set to an instance of an object." I checked
my references and the dll's are there. I have my namespace right and I even
get intellisense to work. I don't get this error anywhere else in my
solution when calling objects in different projects.

Does anyone have any idea what is going on? I have run out of things to
check.

Thanks.

Mike

Can you post the offending piece of code?

Neil
 
I am getting a error that should not be happening when I instantiate an
object from my business layer in a console application within my solution.

I get an "object reference not set to an instance of an object." I checked
my references and the dll's are there. I have my namespace right and I even
get intellisense to work. I don't get this error anywhere else in my
solution when calling objects in different projects.

Does anyone have any idea what is going on? I have run out of things to
check.

Thanks.

Mike
 
Neil,

Here is a snippet:

using Ripple.Common;

using Ripple.Home.BusinessLayer;

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Collections.Specialized;

using System.EnterpriseServices;

namespace Ripple.Home.RemotaDataCollection

{

/// <summary>

/// Summary description for Collector.

/// </summary>

class Collector

{

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main(string[] args)

{

//string x = ConfigurationSettings.AppSettings["Whatever"];

try

{

int ServerID = (int) ServerIDConstant.None;

int ServerTypeID = (int) ServerTypeIDConstant.None;

int Active = 0;

string WebServiceURL = string.Empty;

DataTable dtServer = new DataTable();

BusinessLayer.Server server = new BusinessLayer.Server(); <=== BREAKS
HERE.

/*

* Check for rows.

*/

dtServer = server.ListAll();

if (dtServer.Rows.Count > 0)

{

.... END OF SNIPPET == == == == == ==
 
Hi Mike,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you're getting a NullReferenceException
when trying to instantiate a BusinessLayer.Server object. If there is any
misunderstanding, please feel free to let me know.

Based on the code snippet you have provided, I didn't see anything wrong if
the program breaks on this line.

BusinessLayer.Server server = new BusinessLayer.Server();

So most probably, the exception is thrown from the Server class
constructor. Could you let me know if you're referencing the assembly DLL
in your program or referencing the project? If you have the project of
business layer, you can try to trace into the constructor code to see what
is going wrong.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
If that truely is the line that blows up (have you tried putting Console.WriteLine just before and after? the debugger smetimes reports the wrong line), then I would suspect that the ctor of Server is blowing up. do you have a full stack trace from the exception object?

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Neil,

Here is a snippet:

using Ripple.Common;

using Ripple.Home.BusinessLayer;

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Collections.Specialized;

using System.EnterpriseServices;

namespace Ripple.Home.RemotaDataCollection

{

/// <summary>

/// Summary description for Collector.

/// </summary>

class Collector

{

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main(string[] args)

{

//string x = ConfigurationSettings.AppSettings["Whatever"];

try

{

int ServerID = (int) ServerIDConstant.None;

int ServerTypeID = (int) ServerTypeIDConstant.None;

int Active = 0;

string WebServiceURL = string.Empty;

DataTable dtServer = new DataTable();

BusinessLayer.Server server = new BusinessLayer.Server(); <=== BREAKS
HERE.

/*

* Check for rows.

*/

dtServer = server.ListAll();

if (dtServer.Rows.Count > 0)

{

... END OF SNIPPET == == == == == ==


NWeller said:
Can you post the offending piece of code?

Neil



[microsoft.public.dotnet.languages.csharp]
 
The problem was me.

I was referring to a setting in a config file that did not exist and the call just
died.

Richard Blewett said:
If that truely is the line that blows up (have you tried putting Console.WriteLine
just before and after? the debugger smetimes reports the wrong line), then I would
suspect that the ctor of Server is blowing up. do you have a full stack trace from
the exception object?

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Neil,

Here is a snippet:

using Ripple.Common;

using Ripple.Home.BusinessLayer;

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Collections.Specialized;

using System.EnterpriseServices;

namespace Ripple.Home.RemotaDataCollection

{

/// <summary>

/// Summary description for Collector.

/// </summary>

class Collector

{

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main(string[] args)

{

//string x = ConfigurationSettings.AppSettings["Whatever"];

try

{

int ServerID = (int) ServerIDConstant.None;

int ServerTypeID = (int) ServerTypeIDConstant.None;

int Active = 0;

string WebServiceURL = string.Empty;

DataTable dtServer = new DataTable();

BusinessLayer.Server server = new BusinessLayer.Server(); <=== BREAKS
HERE.

/*

* Check for rows.

*/

dtServer = server.ListAll();

if (dtServer.Rows.Count > 0)

{

... END OF SNIPPET == == == == == ==


NWeller said:
Can you post the offending piece of code?

Neil



[microsoft.public.dotnet.languages.csharp]
 
It was nice to hear that you have had the problem resolved. Thanks for
sharing your experience with all the people here. If you have any
questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top