Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Class inside namespace

Class inside namespace

Scheduled Pinned Locked Moved C#
questionregexhelp
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rick van Woudenberg
    wrote on last edited by
    #1

    Dear all, This morning I encountered a problem I have never had before. I created a project a few weeks back with the namespace CookBook. It compiles and runs just fine. This morning I opened another project with a different namespace. Compiled it, and this project runs fine too. My sick mind thought it would be nice to combine the two projects, however ... two different namespaces. So I imported the second project in the solution of my first project and changed the namespace of the second project to match the first. After changing the namespace, the entire solution compiles fine. I then wanted to refer to a class inside a form in the second project. Since both projects have the same namespace, you would expect the classes in the second form ( with the changed namespace ) to globally show up as CookBook.[class]. However , this is not the case. It simply tells me : No reference , etc during compilation. Can anyone explain to me , what I am doing wrong. I would like the entire second project to be a part of the first project so I can call classes from inside both forms. The projects are pretty large, so importing the forms ( add existing Item ) into the projects is not an option. Do I have to rebuild the class library somehow ( and if so , how do I do that ? ). I'm using VS2005. I highly appreciate any input. Kind regards, and many thanks upfront ! Cheers,

    S P 2 Replies Last reply
    0
    • R Rick van Woudenberg

      Dear all, This morning I encountered a problem I have never had before. I created a project a few weeks back with the namespace CookBook. It compiles and runs just fine. This morning I opened another project with a different namespace. Compiled it, and this project runs fine too. My sick mind thought it would be nice to combine the two projects, however ... two different namespaces. So I imported the second project in the solution of my first project and changed the namespace of the second project to match the first. After changing the namespace, the entire solution compiles fine. I then wanted to refer to a class inside a form in the second project. Since both projects have the same namespace, you would expect the classes in the second form ( with the changed namespace ) to globally show up as CookBook.[class]. However , this is not the case. It simply tells me : No reference , etc during compilation. Can anyone explain to me , what I am doing wrong. I would like the entire second project to be a part of the first project so I can call classes from inside both forms. The projects are pretty large, so importing the forms ( add existing Item ) into the projects is not an option. Do I have to rebuild the class library somehow ( and if so , how do I do that ? ). I'm using VS2005. I highly appreciate any input. Kind regards, and many thanks upfront ! Cheers,

      P Offline
      P Offline
      PandemoniumPasha
      wrote on last edited by
      #2

      i think you have two projects with the same namespace in your solution. in VS2003, (i don't have VS2005:() this would create two separate .dll library files containing only the functions defined in their respective project files. so, if you want to use the function from the second project, you will have to import that file and not the first one. If you want ALL in one file then just combine the two projects together which when compiled will result in a single library file.:rolleyes: there may be other methods but i don't know them:-O i don't know how it works in VS2005, i'm sorry:( regards :)

      1 Reply Last reply
      0
      • R Rick van Woudenberg

        Dear all, This morning I encountered a problem I have never had before. I created a project a few weeks back with the namespace CookBook. It compiles and runs just fine. This morning I opened another project with a different namespace. Compiled it, and this project runs fine too. My sick mind thought it would be nice to combine the two projects, however ... two different namespaces. So I imported the second project in the solution of my first project and changed the namespace of the second project to match the first. After changing the namespace, the entire solution compiles fine. I then wanted to refer to a class inside a form in the second project. Since both projects have the same namespace, you would expect the classes in the second form ( with the changed namespace ) to globally show up as CookBook.[class]. However , this is not the case. It simply tells me : No reference , etc during compilation. Can anyone explain to me , what I am doing wrong. I would like the entire second project to be a part of the first project so I can call classes from inside both forms. The projects are pretty large, so importing the forms ( add existing Item ) into the projects is not an option. Do I have to rebuild the class library somehow ( and if so , how do I do that ? ). I'm using VS2005. I highly appreciate any input. Kind regards, and many thanks upfront ! Cheers,

        S Offline
        S Offline
        Stefan Troschuetz
        wrote on last edited by
        #3

        Having two projects inside the same solution does not make them know anything about each other. In order to use the classes, interfaces, etc. of one project, it has to be referenced by the project that wants to use the stuff. Now that the second project knows about the first one, you can access all things declared public in the first project independent of their namespace.


        "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

        www.troschuetz.de

        R 1 Reply Last reply
        0
        • S Stefan Troschuetz

          Having two projects inside the same solution does not make them know anything about each other. In order to use the classes, interfaces, etc. of one project, it has to be referenced by the project that wants to use the stuff. Now that the second project knows about the first one, you can access all things declared public in the first project independent of their namespace.


          "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

          www.troschuetz.de

          R Offline
          R Offline
          Rick van Woudenberg
          wrote on last edited by
          #4

          Thank you for your kind and swift reply. I was under the impression that importing a project into a solution automatically meant that they know about each other. Obviously not. However, how can I reference a complete project ( or the namespace for that matter ) into a project. using CookBook; at the top of the form is still generating the same error during compilation and so is using the complete name ( namespace.class.method ).

          S R 2 Replies Last reply
          0
          • R Rick van Woudenberg

            Thank you for your kind and swift reply. I was under the impression that importing a project into a solution automatically meant that they know about each other. Obviously not. However, how can I reference a complete project ( or the namespace for that matter ) into a project. using CookBook; at the top of the form is still generating the same error during compilation and so is using the complete name ( namespace.class.method ).

            S Offline
            S Offline
            Stefan Troschuetz
            wrote on last edited by
            #5

            Inside the project explorer right-click on "References" and select the "Add reference..." option. In the dialog that opens that should be a "projects" tab.


            "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

            www.troschuetz.de

            1 Reply Last reply
            0
            • R Rick van Woudenberg

              Thank you for your kind and swift reply. I was under the impression that importing a project into a solution automatically meant that they know about each other. Obviously not. However, how can I reference a complete project ( or the namespace for that matter ) into a project. using CookBook; at the top of the form is still generating the same error during compilation and so is using the complete name ( namespace.class.method ).

              R Offline
              R Offline
              RSArockiam
              wrote on last edited by
              #6

              Try the following way Rightclick the project->add reference->Project->Select the project

              Regards R.Arockiapathinathan

              R 1 Reply Last reply
              0
              • R RSArockiam

                Try the following way Rightclick the project->add reference->Project->Select the project

                Regards R.Arockiapathinathan

                R Offline
                R Offline
                Rick van Woudenberg
                wrote on last edited by
                #7

                Thank you once again for your reply. But adding project A to B , and B to A would create a circular dependency right ?

                R 1 Reply Last reply
                0
                • R Rick van Woudenberg

                  Thank you once again for your reply. But adding project A to B , and B to A would create a circular dependency right ?

                  R Offline
                  R Offline
                  RSArockiam
                  wrote on last edited by
                  #8

                  Yah, its right. If this is the case, you have to restructure you projects and create one more project and push the common things into that project and refer that into both projects.

                  Regards R.Arockiapathinathan

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups