Multiple projects in one C# solution

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon via DotNetMonster.com

    Multiple projects in one C# solution

    Hi all

    I'm creating a Contact Management System. I have added one console project
    and various window projects (for the user interfaces) to the solution.
    I've added these as obviously there will multiple GUI's and I want to store
    all the generic classes in the console project I've added.
    Firstly, is this how you are meant to go about things to achieve my above
    thinking/aim?

    Secondly, in a window project's Button_Click event how do I create an
    object of a class that is stored in the console project? - How do I fully
    qualify it? - i.e. ConsoleName.Nam espaceName.Clas sName temp = new
    ConsoleName.Nam espaceName.Clas sName();

    Does anybody know of any links that explain would the above to me as my C#
    books do not explain this?

    Any help would be very much appreciated.
    Jon (A newcomer to C#).

    --
    Message posted via http://www.dotnetmonster.com
  • Dmitry Rutcovsky

    #2
    Re: Multiple projects in one C# solution

    Hello, Jon!

    JvD> Hi all

    JvD> I'm creating a Contact Management System. I have added one console
    JvD> project and various window projects (for the user interfaces) to the
    JvD> solution. I've added these as obviously there will multiple GUI's and
    JvD> I want to store all the generic classes in the console project I've
    JvD> added. Firstly, is this how you are meant to go about things to
    JvD> achieve my above thinking/aim?

    You should create Class Library project to store all functionality.
    After that you can use classes from this project in other, by doing sme
    steps;
    - add reference to this project (in AddReference Dialog choose Projects
    tab) and add reference to class library project
    - you can use all functionality from this library by full name
    YouLibraryNames pace.YourClass
    or with directive using (using YouLibraryNames pace; ..... /*somewhere in
    code*/ YourClass youClass = new YourClass();)

    - if you need use this functionality in console project, the steps will be
    the same.

    JvD> Secondly, in a window project's Button_Click event how do I create an
    JvD> object of a class that is stored in the console project? - How do I
    JvD> fully qualify it? - i.e. ConsoleName.Nam espaceName.Clas sName temp =
    JvD> new ConsoleName.Nam espaceName.Clas sName();

    see above

    JvD> Does anybody know of any links that explain would the above to me as
    JvD> my C# books do not explain this?

    msdn.microsoft. com :)

    JvD> Any help would be very much appreciated.
    JvD> Jon (A newcomer to C#).

    JvD> --
    JvD> Message posted via http://www.dotnetmonster.com

    With best regards, Dmitry Rutcovsky. E-mail: daima@ukr.net


    Comment

    • Jon via DotNetMonster.com

      #3
      Re: Multiple projects in one C# solution

      Hi Dmitry, I shall look into this. Thanks Jon.

      --
      Message posted via http://www.dotnetmonster.com

      Comment

      • Bob Powell [MVP]

        #4
        Re: Multiple projects in one C# solution

        It sounds as though what you want to do is create a DLL project that's used
        by the other projects in the solution.

        Create a class library project for your utility classes and then ad a
        reference to that project in an GUI projects in the same solution.

        A console application is the wrong choice but I'm sure you can shift the
        utilities to a DLL class library with minimal problems.

        --
        Bob Powell [MVP]
        Visual C#, System.Drawing

        Find great Windows Forms articles in Windows Forms Tips and Tricks


        Answer those GDI+ questions with the GDI+ FAQ


        All new articles provide code in C# and VB.NET.
        Subscribe to the RSS feeds provided and never miss a new article.





        "Jon via DotNetMonster.c om" <forum@nospam.D otNetMonster.co m> wrote in
        message news:4cce70afd3 b94d62b99932b18 c75ae9b@DotNetM onster.com...[color=blue]
        > Hi all
        >
        > I'm creating a Contact Management System. I have added one console
        > project
        > and various window projects (for the user interfaces) to the solution.
        > I've added these as obviously there will multiple GUI's and I want to
        > store
        > all the generic classes in the console project I've added.
        > Firstly, is this how you are meant to go about things to achieve my above
        > thinking/aim?
        >
        > Secondly, in a window project's Button_Click event how do I create an
        > object of a class that is stored in the console project? - How do I fully
        > qualify it? - i.e. ConsoleName.Nam espaceName.Clas sName temp = new
        > ConsoleName.Nam espaceName.Clas sName();
        >
        > Does anybody know of any links that explain would the above to me as my C#
        > books do not explain this?
        >
        > Any help would be very much appreciated.
        > Jon (A newcomer to C#).
        >
        > --
        > Message posted via http://www.dotnetmonster.com[/color]


        Comment

        • Jon via DotNetMonster.com

          #5
          Re: Multiple projects in one C# solution

          Hi Bob, Thanks for your advice too.

          This is to both you and Dmitry. Is a class library the normal place where
          all the application core classes are stored, and not to be stored in the
          form or console files themselves?

          Thanks very much, Jon.

          --
          Message posted via http://www.dotnetmonster.com

          Comment

          • Bob Powell [MVP]

            #6
            Re: Multiple projects in one C# solution

            A console application isn't a good place to try and keep utility classes. A
            DLL is ideal and in fact is designed for just that case. Your class library
            DLL can be accessed and shared by several applications at once. For
            application core classes you might take an architectural descision to
            maintain them in the application if the app wwas stand-alone but if you have
            several "front-ends" for a suite of applications sharing common
            functionality then you'd definitely keep it in a DLL.

            --
            Bob Powell [MVP]
            Visual C#, System.Drawing

            Find great Windows Forms articles in Windows Forms Tips and Tricks


            Answer those GDI+ questions with the GDI+ FAQ


            All new articles provide code in C# and VB.NET.
            Subscribe to the RSS feeds provided and never miss a new article.





            "Jon via DotNetMonster.c om" <forum@DotNetMo nster.com> wrote in message
            news:09e111d4f9 074d7c971c91c2c 30300ea@DotNetM onster.com...[color=blue]
            > Hi Bob, Thanks for your advice too.
            >
            > This is to both you and Dmitry. Is a class library the normal place where
            > all the application core classes are stored, and not to be stored in the
            > form or console files themselves?
            >
            > Thanks very much, Jon.
            >
            > --
            > Message posted via http://www.dotnetmonster.com[/color]


            Comment

            • Jon via DotNetMonster.com

              #7
              Re: Multiple projects in one C# solution

              Bob, Thanks alot. Created one last night. Jon.

              --
              Message posted via http://www.dotnetmonster.com

              Comment

              • Joanna Carter \(TeamB\)

                #8
                Re: Multiple projects in one C# solution

                "Jon via DotNetMonster.c om" <forum@nospam.D otNetMonster.co m> a écrit dans le
                message de news: 4cce70afd3b94d6 2b99932b18c75ae 9b...tMonste r.com...
                [color=blue]
                > Secondly, in a window project's Button_Click event how do I create an
                > object of a class that is stored in the console project? - How do I fully
                > qualify it? - i.e. ConsoleName.Nam espaceName.Clas sName temp = new
                > ConsoleName.Nam espaceName.Clas sName();[/color]

                If you are only using the console project to create classes for use in other
                UI projects then you need to change this to a class library rather than an
                executable project.

                Once you have doen this, then simply add the library project to the
                references of the UI projects and to the 'using' statements of the modules
                that need the classes. Then you don't need to fully qualify the classes when
                you use them.

                Joanna

                --
                Joanna Carter
                Consultant Software Engineer


                Comment

                Working...