471,350 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Trouble with using User Control in different projects

VS.2003, .NET Framework 1.1, C#
My goal: Creating a dll (helper.dll) which contains some UserControls
and some other helpful classes in order to use it in other projects.
Symtoms: The inital use of the UserControl component works. However, if

the Helper Project is recompiled, the UserControl does not work
correctly anymore in the other projects. Furthermore, the previously
visible User Control may not be visible in the Windows Form Designer.
Here the steps I have done:
1) Created a new Project (Helper Project)
2) Added some classes and a UserControl (there are some textboxes,
dropdown boxes, etc.)
Remark: UserControl (ctlHelper.cs)
public class ctlHelper : System.Windows.Forms.UserControl
3) Compiled the procject.
Now the next steps are including the dll in the desire project.
1) Created a new Project
2) Added a new reference to the helper.dll
3) Add -> Add Inherited Control -> Inherited User Control -> Browse to
the helper.dll location -> OK
Now the designed UserControl appears in the Toolbox of VS.2003 under
"My User Controls"
4) Drag & Drop the UserControl to the windows form. Write some code,
This work so far.
But if I made any change in the helper project, compiling it (the
public interface of the helper.dll is untouched!) all Projects which
using the UserControl getting trouble. In all the projects the
UserControl is disappeared from "My User Controls", further, the
Windows Form Designer does not show the UserControl on the Windows Form

as where it was before. The ctlHelper.cs file is still part of the
project. The written code using the UserControl is there, too.
Compiling works too. But if I run the application the UserControl is
not shown in the Windows Form.
The problem is similar as described in KB 818220, but I am useing .NET
Also the workaround works but it is unacceptable. This helper
repository should be used by several programmers in their projects. The

user control should gives consistency across all projects.
What to do in order to get this working?
Any help is appreciated. Thanks in advance.

Jan 25 '06 #1
7 3012
Could this just be a versioning issue?

If you have strong-named your control's assembly, then referencing dlls will
be expecting the exact version.

If you are currently using dynamic version numbers (e.g. 1.0.*.* which uses
the date/time), try pinning it to; alternatively, you could use a
versioning policy in either the GAC or the config file (depending on how it
is deployed)

Not 100% (or even 30%) sure, but well worth a try, if only so you know what
the issue is...

Jan 25 '06 #2
> If you are currently using dynamic version numbers
(e.g. 1.0.*.* which uses the date/time), try pinning it

Quit simply but really really helpful. Thanks for the hint, it seems to
work perfect for the purpose of the helper class.

Thank you a lot!


Jan 25 '06 #3
Glad it helped

Jan 25 '06 #4
Unfortunately the bad behavior is back. Not sure for what reason, but
suddenly the UserControl was disappeared. I have recreated a the
UserControl, used it and after some time, bang :( The version of the
dll is still

Does any alternative to UserControls exist?

Thanks in advance.

Jan 25 '06 #5
My stab-in-the-dark knowledge is exhausted here I'm afraid.

Jan 25 '06 #6
In my experience, if you recompile a library that contains controls
(such as UserControls) then you have to also recompile the project that
uses it before you can use the Designer. Try this after you recompile
your Helper.dll:

1. Switch to the project you want to work on.
2. Close all open Designer windows
3. Rebuild the project.
4. Reopen the Designer windows.

This has always worked for me, and I don't even bother with the version
numbering trick. Is it a bit annoying? Yes. However, UserControls are
so useful that it would be a shame to do some twisted thing in order to
avoid them just so that you don't have to recompile your projects.

Jan 25 '06 #7
Hello Bruce,

Thanks for your suggestion. I will give it a try. You are right, the
numbering trick is a bit annoying, but acceptable if it works. As I
already mentioned, several programmers used this helper library and its
UserControl. Probably most of them do not notice whether the helper dll
is recompiled. Even if you forget to close the Designer window /
rebuild project, you have to recreate the UserControl.

However, it looks like a big trouble spot to use the same UserControl
in different projects.

About UserControl Class from the MSDN:
"You might consider creating a namespace that contains several classes
of user controls and compiling it into one DLL. This DLL can be
referenced and distributed with the application or all applications
within an organization. This gives you the ability to reference the
user control in many applications and save time laying out and coding
the contained elements of the user control. A user control also gives
you consistency within or across applications; for example, all address
information input blocks will all have the same appearance and
behavior. Consistency gives your application a more polished and
professional appearance."

Yeah, this is exactly what I need. Therefore I am sure that I missed a
important point, because it can't so buggy to use it.

Any further suggestions/hints are very welcome.

Jan 26 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Penn Markham | last post: by
reply views Thread by Tariq Ahmad | last post: by
4 posts views Thread by Josh Harris | last post: by
14 posts views Thread by pmud | last post: by
16 posts views Thread by scorpion53061 | last post: by
4 posts views Thread by Jenni.Haughton | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.