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. Unable to figure out a proper subject line. Sorry. :(

Unable to figure out a proper subject line. Sorry. :(

Scheduled Pinned Locked Moved C#
helpquestion
19 Posts 8 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.
  • D Offline
    D Offline
    dashingsidds
    wrote on last edited by
    #1

    Hi Experts, First of all sorry for not figuring out a proper subject line for the problem i am facing. Consider that I have 3 projects with me. 1. DefineEnum 2. UseEnumInMethod 3. UseMethod The first project defines an enum just like any other project i.e.

        public enum MyEnum
        {
            value1 = 0,
            value2 = 1
        }
    

    The second project i.e. "UseEnumInMethod" has a method defined in it which has the above mentioned enum as a type to its parameter as

        public void UseDefinedEnums(MyEnum \_enum)
        { 
            //Any code here.
        }
    

    I can get the "MyEnum" as a type to the parameter of the method here by adding the project reference of "DefineEnum" in project "UseEnumInMethod". Now when i want to use the above method in my third project i.e. in "UseMethod" I have to give the reference of both the projects 1 and 2 in the 3rd project if I want to use it as follows.

        public void Test()
        {
            UseDefinedEnums(MyEnum.value1);
        }
    

    My question here is, is it possible to avoid giving the reference of the 1st project in the 3rd project and still avail the above functionality? Anyone Please help! Thanks in advance! Regards, Samar

    L P A K L 5 Replies Last reply
    0
    • D dashingsidds

      Hi Experts, First of all sorry for not figuring out a proper subject line for the problem i am facing. Consider that I have 3 projects with me. 1. DefineEnum 2. UseEnumInMethod 3. UseMethod The first project defines an enum just like any other project i.e.

          public enum MyEnum
          {
              value1 = 0,
              value2 = 1
          }
      

      The second project i.e. "UseEnumInMethod" has a method defined in it which has the above mentioned enum as a type to its parameter as

          public void UseDefinedEnums(MyEnum \_enum)
          { 
              //Any code here.
          }
      

      I can get the "MyEnum" as a type to the parameter of the method here by adding the project reference of "DefineEnum" in project "UseEnumInMethod". Now when i want to use the above method in my third project i.e. in "UseMethod" I have to give the reference of both the projects 1 and 2 in the 3rd project if I want to use it as follows.

          public void Test()
          {
              UseDefinedEnums(MyEnum.value1);
          }
      

      My question here is, is it possible to avoid giving the reference of the 1st project in the 3rd project and still avail the above functionality? Anyone Please help! Thanks in advance! Regards, Samar

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      dashingsidds wrote:

      is it possible to avoid giving the reference of the 1st project in the 3rd project and still avail the above functionality?

      Consider the problem, if you do not give the reference then how is the compiler to determine what you mean when you refer to a MyEnum variable?

      It's time for a new signature.

      D 1 Reply Last reply
      0
      • D dashingsidds

        Hi Experts, First of all sorry for not figuring out a proper subject line for the problem i am facing. Consider that I have 3 projects with me. 1. DefineEnum 2. UseEnumInMethod 3. UseMethod The first project defines an enum just like any other project i.e.

            public enum MyEnum
            {
                value1 = 0,
                value2 = 1
            }
        

        The second project i.e. "UseEnumInMethod" has a method defined in it which has the above mentioned enum as a type to its parameter as

            public void UseDefinedEnums(MyEnum \_enum)
            { 
                //Any code here.
            }
        

        I can get the "MyEnum" as a type to the parameter of the method here by adding the project reference of "DefineEnum" in project "UseEnumInMethod". Now when i want to use the above method in my third project i.e. in "UseMethod" I have to give the reference of both the projects 1 and 2 in the 3rd project if I want to use it as follows.

            public void Test()
            {
                UseDefinedEnums(MyEnum.value1);
            }
        

        My question here is, is it possible to avoid giving the reference of the 1st project in the 3rd project and still avail the above functionality? Anyone Please help! Thanks in advance! Regards, Samar

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        dashingsidds wrote:

        is it possible to avoid giving the reference of the 1st project in the 3rd project and still avail the above functionality?

        No. If you try to use the 2nd project in the 3rd project, then ALL of the items that the 2nd project is dependent on must be satisfied in the 3rd project.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

        My blog | My articles | MoXAML PowerToys | Onyx

        D 1 Reply Last reply
        0
        • L Lost User

          dashingsidds wrote:

          is it possible to avoid giving the reference of the 1st project in the 3rd project and still avail the above functionality?

          Consider the problem, if you do not give the reference then how is the compiler to determine what you mean when you refer to a MyEnum variable?

          It's time for a new signature.

          D Offline
          D Offline
          dashingsidds
          wrote on last edited by
          #4

          Hi Richard, That is the exact challenge i am facing. In my scenario i cannot give the reference of the 1st project in the third project as i have mentioned. And if I do not give the reference, the third project will not know if the enum "MyEnum" actually exists just as you have mentioned. Maybe i need to create a wrapper in the second project which will expose the enum declared in the first project but i am unable to figure out how am i suppose to go about doing that. Regards, Samar

          L P 2 Replies Last reply
          0
          • P Pete OHanlon

            dashingsidds wrote:

            is it possible to avoid giving the reference of the 1st project in the 3rd project and still avail the above functionality?

            No. If you try to use the 2nd project in the 3rd project, then ALL of the items that the 2nd project is dependent on must be satisfied in the 3rd project.

            "WPF has many lovers. It's a veritable porn star!" - Josh Smith

            As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

            My blog | My articles | MoXAML PowerToys | Onyx

            D Offline
            D Offline
            dashingsidds
            wrote on last edited by
            #5

            Hmm. I see your point Pete. But just a thought, is it possible that we create a wrapper (a class maybe) in the second project which will expose the functionality given in the first project?? The only problem here is i am unable to figure how am i suppose to do that!! :(( Regards, Samar

            P L 2 Replies Last reply
            0
            • D dashingsidds

              Hmm. I see your point Pete. But just a thought, is it possible that we create a wrapper (a class maybe) in the second project which will expose the functionality given in the first project?? The only problem here is i am unable to figure how am i suppose to do that!! :(( Regards, Samar

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              If you are defining it in your 2nd project, then what purpose does the 1st one serve?

              "WPF has many lovers. It's a veritable porn star!" - Josh Smith

              As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

              My blog | My articles | MoXAML PowerToys | Onyx

              1 Reply Last reply
              0
              • D dashingsidds

                Hmm. I see your point Pete. But just a thought, is it possible that we create a wrapper (a class maybe) in the second project which will expose the functionality given in the first project?? The only problem here is i am unable to figure how am i suppose to do that!! :(( Regards, Samar

                L Offline
                L Offline
                Lukasz Nowakowski
                wrote on last edited by
                #7

                It is possible, but notice, that you have (in the project 2, your "wrapper") a public method that takes enum you want to hide as a parameter. Therefore project 3 must know what this enum is (event if it didn't use the method). If you redesign the middle layer, so it doesn't expose your enum anywhere it should work probably work as you want, but a question arrises if it's worth the effort. But, there's "but". Even if you redesign it, and you won't have reference to project 1 from project 3, output of the project 1 (dll) will still make it to the output of the application.

                1 Reply Last reply
                0
                • D dashingsidds

                  Hi Richard, That is the exact challenge i am facing. In my scenario i cannot give the reference of the 1st project in the third project as i have mentioned. And if I do not give the reference, the third project will not know if the enum "MyEnum" actually exists just as you have mentioned. Maybe i need to create a wrapper in the second project which will expose the enum declared in the first project but i am unable to figure out how am i suppose to go about doing that. Regards, Samar

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  dashingsidds wrote:

                  i cannot give the reference of the 1st project in the third project

                  OK, but you have not explained why you cannot do this, or what problem you are trying to solve. Maybe if you explain a bit more about what you are trying to do we can offer some suggestions.

                  It's time for a new signature.

                  1 Reply Last reply
                  0
                  • D dashingsidds

                    Hi Experts, First of all sorry for not figuring out a proper subject line for the problem i am facing. Consider that I have 3 projects with me. 1. DefineEnum 2. UseEnumInMethod 3. UseMethod The first project defines an enum just like any other project i.e.

                        public enum MyEnum
                        {
                            value1 = 0,
                            value2 = 1
                        }
                    

                    The second project i.e. "UseEnumInMethod" has a method defined in it which has the above mentioned enum as a type to its parameter as

                        public void UseDefinedEnums(MyEnum \_enum)
                        { 
                            //Any code here.
                        }
                    

                    I can get the "MyEnum" as a type to the parameter of the method here by adding the project reference of "DefineEnum" in project "UseEnumInMethod". Now when i want to use the above method in my third project i.e. in "UseMethod" I have to give the reference of both the projects 1 and 2 in the 3rd project if I want to use it as follows.

                        public void Test()
                        {
                            UseDefinedEnums(MyEnum.value1);
                        }
                    

                    My question here is, is it possible to avoid giving the reference of the 1st project in the 3rd project and still avail the above functionality? Anyone Please help! Thanks in advance! Regards, Samar

                    A Offline
                    A Offline
                    Abhinav S
                    wrote on last edited by
                    #9

                    dashingsidds wrote:

                    My question here is, is it possible to avoid giving the reference of the 1st project in the 3rd project and still avail the above functionality?

                    No. Unless you use a web service to expose your first project. You would then be generating a proxy for your this class in wherever you want to consume your web service.

                    My signature "sucks" today

                    1 Reply Last reply
                    0
                    • D dashingsidds

                      Hi Experts, First of all sorry for not figuring out a proper subject line for the problem i am facing. Consider that I have 3 projects with me. 1. DefineEnum 2. UseEnumInMethod 3. UseMethod The first project defines an enum just like any other project i.e.

                          public enum MyEnum
                          {
                              value1 = 0,
                              value2 = 1
                          }
                      

                      The second project i.e. "UseEnumInMethod" has a method defined in it which has the above mentioned enum as a type to its parameter as

                          public void UseDefinedEnums(MyEnum \_enum)
                          { 
                              //Any code here.
                          }
                      

                      I can get the "MyEnum" as a type to the parameter of the method here by adding the project reference of "DefineEnum" in project "UseEnumInMethod". Now when i want to use the above method in my third project i.e. in "UseMethod" I have to give the reference of both the projects 1 and 2 in the 3rd project if I want to use it as follows.

                          public void Test()
                          {
                              UseDefinedEnums(MyEnum.value1);
                          }
                      

                      My question here is, is it possible to avoid giving the reference of the 1st project in the 3rd project and still avail the above functionality? Anyone Please help! Thanks in advance! Regards, Samar

                      K Offline
                      K Offline
                      Kunal Chowdhury IN
                      wrote on last edited by
                      #10

                      dashingsidds wrote:

                      Now when i want to use the above method in my third project i.e. in "UseMethod" I have to give the reference of both the projects 1 and 2 in the 3rd project if I want to use it as follows. public void Test() { UseDefinedEnums(MyEnum.value1); } My question here is, is it possible to avoid giving the reference of the 1st project in the 3rd project and still avail the above functionality?

                      Hi Samar, You can't do it as you are using both the two projects inside the third one. You must have to add the reference of the two projects in the third one.

                      Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.


                      Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial

                      1 Reply Last reply
                      0
                      • D dashingsidds

                        Hi Richard, That is the exact challenge i am facing. In my scenario i cannot give the reference of the 1st project in the third project as i have mentioned. And if I do not give the reference, the third project will not know if the enum "MyEnum" actually exists just as you have mentioned. Maybe i need to create a wrapper in the second project which will expose the enum declared in the first project but i am unable to figure out how am i suppose to go about doing that. Regards, Samar

                        P Offline
                        P Offline
                        PIEBALDconsult
                        wrote on last edited by
                        #11

                        dashingsidds wrote:

                        i cannot give the reference of the 1st project in the third project

                        You'll have a hard time defending that statement.

                        D 1 Reply Last reply
                        0
                        • D dashingsidds

                          Hi Experts, First of all sorry for not figuring out a proper subject line for the problem i am facing. Consider that I have 3 projects with me. 1. DefineEnum 2. UseEnumInMethod 3. UseMethod The first project defines an enum just like any other project i.e.

                              public enum MyEnum
                              {
                                  value1 = 0,
                                  value2 = 1
                              }
                          

                          The second project i.e. "UseEnumInMethod" has a method defined in it which has the above mentioned enum as a type to its parameter as

                              public void UseDefinedEnums(MyEnum \_enum)
                              { 
                                  //Any code here.
                              }
                          

                          I can get the "MyEnum" as a type to the parameter of the method here by adding the project reference of "DefineEnum" in project "UseEnumInMethod". Now when i want to use the above method in my third project i.e. in "UseMethod" I have to give the reference of both the projects 1 and 2 in the 3rd project if I want to use it as follows.

                              public void Test()
                              {
                                  UseDefinedEnums(MyEnum.value1);
                              }
                          

                          My question here is, is it possible to avoid giving the reference of the 1st project in the 3rd project and still avail the above functionality? Anyone Please help! Thanks in advance! Regards, Samar

                          L Offline
                          L Offline
                          Luc Pattyn
                          wrote on last edited by
                          #12

                          This is analogous: here is a method that calculates the square of a number:

                          public static Number Square(Number aNumber) {...}

                          now start using it. BTW I will not tell you what Number is. You should see immediately it can't be done, how can you use something when it relies on stuff that is not available? :)

                          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                          I only read formatted code with indentation, so please use PRE tags for code snippets.


                          I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


                          D 1 Reply Last reply
                          0
                          • L Luc Pattyn

                            This is analogous: here is a method that calculates the square of a number:

                            public static Number Square(Number aNumber) {...}

                            now start using it. BTW I will not tell you what Number is. You should see immediately it can't be done, how can you use something when it relies on stuff that is not available? :)

                            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                            I only read formatted code with indentation, so please use PRE tags for code snippets.


                            I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


                            D Offline
                            D Offline
                            dashingsidds
                            wrote on last edited by
                            #13

                            Hi Luc, I get your point here but i think you misunderstood me a little. I know it is not possible to get a class which is not present anywhere in the project or in the referenced assemblies. What I was thinking here is, if possible, we can build a wrapper class in the second project which will expose the methods in the first project. In this way the second project's assembly will contain the methods of the first assembly as well and hence need not give an explicit reference of the first project in the third project. The problem here is i am unable to figure out how am i going to do that??? :(( I hope u r getting me here. If this is not possible then i am willing to leave trying this. :(( Regards, Samar

                            L 1 Reply Last reply
                            0
                            • D dashingsidds

                              Hi Luc, I get your point here but i think you misunderstood me a little. I know it is not possible to get a class which is not present anywhere in the project or in the referenced assemblies. What I was thinking here is, if possible, we can build a wrapper class in the second project which will expose the methods in the first project. In this way the second project's assembly will contain the methods of the first assembly as well and hence need not give an explicit reference of the first project in the third project. The problem here is i am unable to figure out how am i going to do that??? :(( I hope u r getting me here. If this is not possible then i am willing to leave trying this. :(( Regards, Samar

                              L Offline
                              L Offline
                              Luc Pattyn
                              wrote on last edited by
                              #14

                              in your example, the method of the middle DLL was using a type from the first DLL as a parameter, hence that type had to be available to the final EXE. if none of the public API of DLL 2 needs types from DLL 1, then of course your EXE would not care about DLL 1 itself, as all it sees is the public stuff of DLL 2. The EXE is not interested in how DLL 2 is implemented, nor what it may need internally. That is normal when using libraries, packages, etc. Example: when I use a WebBrowser, it relies on several DLL (I admit, those probably are unmanaged) thast belong to Internet Explorer; my app does not need to know any detail, as all the API parts of WebBrowser are regular .NET types. So you can wrap methods; you can hide classes and types in general. But you cannot actively use classes/types without knowing them. :)

                              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                              I only read formatted code with indentation, so please use PRE tags for code snippets.


                              I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


                              D 1 Reply Last reply
                              0
                              • P PIEBALDconsult

                                dashingsidds wrote:

                                i cannot give the reference of the 1st project in the third project

                                You'll have a hard time defending that statement.

                                D Offline
                                D Offline
                                dashingsidds
                                wrote on last edited by
                                #15

                                Hi PIEBALD, I can defend that. My team here is building a framwork which will have a single assembly which will be used in further projects. The requirement from the client here is this framework should contain just 1 assembly and not more than that. Now while building this framwork we realised that we had to create 2 assemblies instead of 1 (please dont ask why :(( ) , in my example above, project 1 and 2. Now just as i said we cannot give 2 assemblies to the client which will reference in his project that is why all this head-breaking is goin on here. I hope i have defended my stance well. :) Regards, Samar

                                P 1 Reply Last reply
                                0
                                • L Luc Pattyn

                                  in your example, the method of the middle DLL was using a type from the first DLL as a parameter, hence that type had to be available to the final EXE. if none of the public API of DLL 2 needs types from DLL 1, then of course your EXE would not care about DLL 1 itself, as all it sees is the public stuff of DLL 2. The EXE is not interested in how DLL 2 is implemented, nor what it may need internally. That is normal when using libraries, packages, etc. Example: when I use a WebBrowser, it relies on several DLL (I admit, those probably are unmanaged) thast belong to Internet Explorer; my app does not need to know any detail, as all the API parts of WebBrowser are regular .NET types. So you can wrap methods; you can hide classes and types in general. But you cannot actively use classes/types without knowing them. :)

                                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                                  I only read formatted code with indentation, so please use PRE tags for code snippets.


                                  I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


                                  D Offline
                                  D Offline
                                  dashingsidds
                                  wrote on last edited by
                                  #16

                                  So Luc you are saying there is no way i can refer the methods or classes from the 1st project in the 3rd project without referencing it??? Not even by creating a wrapper class or something in the second project and then using that wrapper class in the third project?? Hmm.. A little hard to believe, for me atleast.. :(( Thanks a million for your time and help Luc. Regards, Samar

                                  L 1 Reply Last reply
                                  0
                                  • D dashingsidds

                                    So Luc you are saying there is no way i can refer the methods or classes from the 1st project in the 3rd project without referencing it??? Not even by creating a wrapper class or something in the second project and then using that wrapper class in the third project?? Hmm.. A little hard to believe, for me atleast.. :(( Thanks a million for your time and help Luc. Regards, Samar

                                    L Offline
                                    L Offline
                                    Luc Pattyn
                                    wrote on last edited by
                                    #17

                                    dashingsidds wrote:

                                    So Luc you are saying there is no way i can refer the methods ...

                                    That is not what I said; you can refer everything that is public as long as you know all the types required to access it: the type that contains the method, the parameter types and the return type. If I sell you a graphics package and deliver one DLL, you can use it by adding a reference to it in your project, and referring to whatever is public. When I release a version 2, I may have split the DLL in seven DLLs; as long as one of them still has the original name and makes the original types available, for you nothing has changed. How things are organized amongst those seven DLLs is of no concern of yours. What I should not do, is migrate a public type from the original DLL to some other DLL though; if I did that, you would need a reference to access that type. :)

                                    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                                    I only read formatted code with indentation, so please use PRE tags for code snippets.


                                    I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


                                    D 1 Reply Last reply
                                    0
                                    • L Luc Pattyn

                                      dashingsidds wrote:

                                      So Luc you are saying there is no way i can refer the methods ...

                                      That is not what I said; you can refer everything that is public as long as you know all the types required to access it: the type that contains the method, the parameter types and the return type. If I sell you a graphics package and deliver one DLL, you can use it by adding a reference to it in your project, and referring to whatever is public. When I release a version 2, I may have split the DLL in seven DLLs; as long as one of them still has the original name and makes the original types available, for you nothing has changed. How things are organized amongst those seven DLLs is of no concern of yours. What I should not do, is migrate a public type from the original DLL to some other DLL though; if I did that, you would need a reference to access that type. :)

                                      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                                      I only read formatted code with indentation, so please use PRE tags for code snippets.


                                      I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


                                      D Offline
                                      D Offline
                                      dashingsidds
                                      wrote on last edited by
                                      #18

                                      Hmm... I got that. So how do I apply the thing you just said in my scenario??? Or what do I need to change to make this work??? Please note that in my case creating 2 assemblies is inevitable. Also I cannot provide more than 1 assembly to the client. Please advice. Regards, Samar

                                      1 Reply Last reply
                                      0
                                      • D dashingsidds

                                        Hi PIEBALD, I can defend that. My team here is building a framwork which will have a single assembly which will be used in further projects. The requirement from the client here is this framework should contain just 1 assembly and not more than that. Now while building this framwork we realised that we had to create 2 assemblies instead of 1 (please dont ask why :(( ) , in my example above, project 1 and 2. Now just as i said we cannot give 2 assemblies to the client which will reference in his project that is why all this head-breaking is goin on here. I hope i have defended my stance well. :) Regards, Samar

                                        P Offline
                                        P Offline
                                        PIEBALDconsult
                                        wrote on last edited by
                                        #19

                                        You didn't defend "cannot" -- the actual inability to do it; you merely stated a prohibition not to do it. Then you must have everything in one assembly.

                                        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