Class inside namespace
-
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 asCookBook.[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, -
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 asCookBook.[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,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 :)
-
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 asCookBook.[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,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
-
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
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 ). -
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 ).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
-
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 ).Try the following way Rightclick the project->add reference->Project->Select the project
Regards R.Arockiapathinathan
-
Try the following way Rightclick the project->add reference->Project->Select the project
Regards R.Arockiapathinathan
Thank you once again for your reply. But adding project A to B , and B to A would create a circular dependency right ?
-
Thank you once again for your reply. But adding project A to B , and B to A would create a circular dependency right ?
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