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. Control development

Control development

Scheduled Pinned Locked Moved C#
csharpgame-devdebuggingquestionannouncement
13 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.
  • P Offline
    P Offline
    PaleyX
    wrote on last edited by
    #1

    In my .NET solution I have a project which has the controls I have developed for use in the main project. If I add the controls in that project to the toolbox I am adding them from the Debug directory. When I compile the controls for release will the main project still be referencing the debug code? Rugby League: The Greatest Game Of All.

    R 1 Reply Last reply
    0
    • P PaleyX

      In my .NET solution I have a project which has the controls I have developed for use in the main project. If I add the controls in that project to the toolbox I am adding them from the Debug directory. When I compile the controls for release will the main project still be referencing the debug code? Rugby League: The Greatest Game Of All.

      R Offline
      R Offline
      Robert Rohde
      wrote on last edited by
      #2

      Its not important how youve dragged the controls into the toolbox. Its important what reference your main project has. If it has a real project reference to your project with the controls then everything should be fine when building in release mode.

      P 2 Replies Last reply
      0
      • R Robert Rohde

        Its not important how youve dragged the controls into the toolbox. Its important what reference your main project has. If it has a real project reference to your project with the controls then everything should be fine when building in release mode.

        P Offline
        P Offline
        PaleyX
        wrote on last edited by
        #3

        Thanks, how do I do that? I just tried building in release mode and every control from the control project dissapeared. I added the controls to the toolbox using the add/remove dialog and then "browse"

        H 1 Reply Last reply
        0
        • R Robert Rohde

          Its not important how youve dragged the controls into the toolbox. Its important what reference your main project has. If it has a real project reference to your project with the controls then everything should be fine when building in release mode.

          P Offline
          P Offline
          PaleyX
          wrote on last edited by
          #4

          I have some controls inherited from UserControl in the sub project and they appear in the toolbox on the My Controls tab but I also have some controls which inherit from Control - how do I get those to appear in the toolbox? At the moment I am editing the code generated by the IDE in the "Windows Form Designer Code" in order to use them which, of course, means they can be gotten rid of at any time. I just want to be able to drag them from the toolbox. How do I do that?

          1 Reply Last reply
          0
          • P PaleyX

            Thanks, how do I do that? I just tried building in release mode and every control from the control project dissapeared. I added the controls to the toolbox using the add/remove dialog and then "browse"

            H Offline
            H Offline
            Heath Stewart
            wrote on last edited by
            #5

            Right-click on your project and select Add Reference. Click the Projects tab and select a dependent project in your solution. This makes sure that you're always building against the most up-to-date assembly (because it establishes a build dependency) and that you're using the right build configuration (so a release build uses the release assembly from the dependent project). Any control extending UserControl appears automatically in the toolbox. Do not add it yourself. In fact, don't use the toolbox for the project you're developing within the solution. You'll be changing them often. If you develop in-house controls for use in a project, control the release cycle similar to how you would for a public project and then you could add them to the toolbox. The toolbox is meant for stable controls, not controls you're developing otherwise you will have the problems you're having. If you need to add a control you're developing to a container control initially, add it manually. It's not hard. Open the source code for the container control (like the Form you're designing), add a private field like you see for other controls, then instantiate it in the InitializeComponent method like you see for the other controls. When you switch back to the designer you can design it like all the other controls you added from the toolbox. It's a one-time process that only takes a few seconds, compared to the time you'll be spending working around problems with adding controls in development to the toolbox. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

            P 1 Reply Last reply
            0
            • H Heath Stewart

              Right-click on your project and select Add Reference. Click the Projects tab and select a dependent project in your solution. This makes sure that you're always building against the most up-to-date assembly (because it establishes a build dependency) and that you're using the right build configuration (so a release build uses the release assembly from the dependent project). Any control extending UserControl appears automatically in the toolbox. Do not add it yourself. In fact, don't use the toolbox for the project you're developing within the solution. You'll be changing them often. If you develop in-house controls for use in a project, control the release cycle similar to how you would for a public project and then you could add them to the toolbox. The toolbox is meant for stable controls, not controls you're developing otherwise you will have the problems you're having. If you need to add a control you're developing to a container control initially, add it manually. It's not hard. Open the source code for the container control (like the Form you're designing), add a private field like you see for other controls, then instantiate it in the InitializeComponent method like you see for the other controls. When you switch back to the designer you can design it like all the other controls you added from the toolbox. It's a one-time process that only takes a few seconds, compared to the time you'll be spending working around problems with adding controls in development to the toolbox. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

              P Offline
              P Offline
              PaleyX
              wrote on last edited by
              #6

              Thanks for replying. That's exactly what I am doing. I have a control which inherits from Control so it doesn't appear in the toolbox so I instantiate it myself - however the IDE just gets rid of it sometimes - I thought we weren't supposed to change any code in IntializeComponent. I have project references in the main project but as soon as I switch to Release build all the controls from the controls project disappear from the main project. I have been at this for a while now and can't get it to work at all.

              D H 2 Replies Last reply
              0
              • P PaleyX

                Thanks for replying. That's exactly what I am doing. I have a control which inherits from Control so it doesn't appear in the toolbox so I instantiate it myself - however the IDE just gets rid of it sometimes - I thought we weren't supposed to change any code in IntializeComponent. I have project references in the main project but as soon as I switch to Release build all the controls from the controls project disappear from the main project. I have been at this for a while now and can't get it to work at all.

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                You might have covered this already, but did you check the AssemblyVersionAttribute tag, in assembly.cs if you have one, to make sure it doesn't have any * in it? Replace the * with a number so the version number stays constant from build to build while your developing your control. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                P H 2 Replies Last reply
                0
                • D Dave Kreskowiak

                  You might have covered this already, but did you check the AssemblyVersionAttribute tag, in assembly.cs if you have one, to make sure it doesn't have any * in it? Replace the * with a number so the version number stays constant from build to build while your developing your control. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                  P Offline
                  P Offline
                  PaleyX
                  wrote on last edited by
                  #8

                  That appears to have worked. Thanks for your help. Rugby League: The Greatest Game Of All.

                  1 Reply Last reply
                  0
                  • D Dave Kreskowiak

                    You might have covered this already, but did you check the AssemblyVersionAttribute tag, in assembly.cs if you have one, to make sure it doesn't have any * in it? Replace the * with a number so the version number stays constant from build to build while your developing your control. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                    H Offline
                    H Offline
                    Heath Stewart
                    wrote on last edited by
                    #9

                    While it's a good idea to control your versions, this isn't necessary when you use a project reference as opposed to an assembly reference. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

                    D 1 Reply Last reply
                    0
                    • P PaleyX

                      Thanks for replying. That's exactly what I am doing. I have a control which inherits from Control so it doesn't appear in the toolbox so I instantiate it myself - however the IDE just gets rid of it sometimes - I thought we weren't supposed to change any code in IntializeComponent. I have project references in the main project but as soon as I switch to Release build all the controls from the controls project disappear from the main project. I have been at this for a while now and can't get it to work at all.

                      H Offline
                      H Offline
                      Heath Stewart
                      wrote on last edited by
                      #10

                      If you dragged a component from the toolbox than you've got an assembly reference. Project references are recompiled (if necessary) before your project is recompiled, and the assembly is copied locally to your project's target directory. If your controls are disappearing it's most likely because your project is referencing a specific version of the assembly you added originally (and versions greatly matter for assemblies, unlike native DLLs) that is no longer available. If Dave's suggestion worked, great, but you will still face a problem when you do have to change your assembly version. Be sure to remove all assembly references to projects in your solution and use project references. You can modify InitializeComponent, but if you don't do it in a designer-friendly manner the designer will not work. Just use the same pattern of code that the designer expects and you'll be fine. I used to do it all the time in the same exact scenario you describe now. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

                      P 1 Reply Last reply
                      0
                      • H Heath Stewart

                        If you dragged a component from the toolbox than you've got an assembly reference. Project references are recompiled (if necessary) before your project is recompiled, and the assembly is copied locally to your project's target directory. If your controls are disappearing it's most likely because your project is referencing a specific version of the assembly you added originally (and versions greatly matter for assemblies, unlike native DLLs) that is no longer available. If Dave's suggestion worked, great, but you will still face a problem when you do have to change your assembly version. Be sure to remove all assembly references to projects in your solution and use project references. You can modify InitializeComponent, but if you don't do it in a designer-friendly manner the designer will not work. Just use the same pattern of code that the designer expects and you'll be fine. I used to do it all the time in the same exact scenario you describe now. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

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

                        Thanks for replying. How do I tell if a reference is an assembly reference or a project reference?

                        H 1 Reply Last reply
                        0
                        • H Heath Stewart

                          While it's a good idea to control your versions, this isn't necessary when you use a project reference as opposed to an assembly reference. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

                          D Offline
                          D Offline
                          Dave Kreskowiak
                          wrote on last edited by
                          #12

                          Something just didn't sound right about what he was doing. At least with this method, we know for a fact he wasn't using project references. Thanks for spelling it out for him! :-D RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                          1 Reply Last reply
                          0
                          • P PaleyX

                            Thanks for replying. How do I tell if a reference is an assembly reference or a project reference?

                            H Offline
                            H Offline
                            Heath Stewart
                            wrote on last edited by
                            #13

                            You as the developer don't know what comprises your own project? If you need to check, right-click on your solution and select Configuration Manager. Look at the dependencies for your project by selecting your project from the drop-down. If there's a disabled checked checkbox, then you're got a project reference. If not, you're referencing an assembly. You can also open the .sln file (your solution file) in notepad or some other plain-text editor and look at the solution text to see what is listed. It should be quite obvious. For a 60+ project solution I used to manage while a senior software architect for another company I never once had a problem - nor did any of my developers - because we all used project references. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]

                            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