class files into dll

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hrvoje Voda

    class files into dll

    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 "SetConnectionS tring(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.Collecti ons;

    using System.Componen tModel;

    using System.Windows. Forms;

    using LoginDb;

    namespace UserLogin

    {

    public class Logon

    {

    LoginDb.Db db = null;



    public Logon()

    {


    }

    public void SetConnectionSt ring(string sConnString)

    {

    db = new Db(sConnString) ;

    }



    }

    }



    Hrcko


  • Jon Skeet [C# MVP]

    #2
    Re: class files into dll

    Hrvoje Voda <hrvoje.voda@lu atech.com> wrote:[color=blue]
    > 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 "SetConnectionS tring(string sConnString)"
    > in users class I get an error : Object reference not set to an instance of
    > an object !
    >
    > Why ?[/color]

    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 SetConnectionSt ring 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.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Ziga Jakhel

      #3
      Re: class files into dll

      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



      "Hrvoje Voda" <hrvoje.voda@lu atech.com> wrote in message
      news:d7hdta$4bm $1@ss405.t-com.hr...[color=blue]
      >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 "SetConnectionS tring(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.Collecti ons;
      >
      > using System.Componen tModel;
      >
      > using System.Windows. Forms;
      >
      > using LoginDb;
      >
      > namespace UserLogin
      >
      > {
      >
      > public class Logon
      >
      > {
      >
      > LoginDb.Db db = null;
      >
      >
      >
      > public Logon()
      >
      > {
      >
      >
      > }
      >
      > public void SetConnectionSt ring(string sConnString)
      >
      > {
      >
      > db = new Db(sConnString) ;
      >
      > }
      >
      >
      >
      > }
      >
      > }
      >
      >
      >
      > Hrcko
      >
      >[/color]


      Comment

      Working...