Control development
-
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.
-
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.
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.
-
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.
-
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.
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?
-
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"
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 theForm
you're designing), add a private field like you see for other controls, then instantiate it in theInitializeComponent
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] -
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 theForm
you're designing), add a private field like you see for other controls, then instantiate it in theInitializeComponent
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]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.
-
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.
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
-
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
-
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
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]
-
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.
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] -
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] -
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]
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
-
Thanks for replying. How do I tell if a reference is an assembly reference or a project reference?
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]