class files into dll

H

Hrvoje Voda

I have created a project solution with two class projects.

One is used to give information about user and the other one is a dataset
connection properties.

The class with users has reference to dataset.

Now, I created an dll of those project solution.

But, when I call a public function "SetConnectionString(string sConnString)"
in users class I get an error : Object reference not set to an instance of
an object !

Why ?

public class in users :

using System;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using LoginDb;

namespace UserLogin

{

public class Logon

{

LoginDb.Db db = null;



public Logon()

{


}

public void SetConnectionString(string sConnString)

{

db = new Db(sConnString);

}



}

}



Hrcko
 
J

Jon Skeet [C# MVP]

Hrvoje Voda said:
I have created a project solution with two class projects.

One is used to give information about user and the other one is a dataset
connection properties.

The class with users has reference to dataset.

Now, I created an dll of those project solution.

But, when I call a public function "SetConnectionString(string sConnString)"
in users class I get an error : Object reference not set to an instance of
an object !

Why ?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

The obvious answer is that you may be calling SetConnectionString on a
null reference rather than on a reference to an instance of Logon.
Without seeing the calling code, it's impossible to say.

It's unlikely to be anything to do with doing it in a separate library
though.
 
Z

Ziga Jakhel

Hrcko:

1) I presume the sConnString is not null?

2) Judging by the code you posted this sounds like a problem in the LoginDB
Class constructor.

Try putting the db = new DB(sConnString) into a try... catch block and/or
step through what exactly happens in the DB constructor.
Review the exception information and stacktrace on where exactly the error
occured.


Bok,

Ziga Jakhel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top