By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,489 Members | 1,284 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,489 IT Pros & Developers. It's quick & easy.

Trouble with using User Control in different projects

P: n/a
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,
compile.
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
UserControl.
http://support.microsoft.com/?kbid=818220
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.
cw

Jan 25 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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 1.0.0.0; 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...

Marc
Jan 25 '06 #2

P: n/a
> If you are currently using dynamic version numbers
(e.g. 1.0.*.* which uses the date/time), try pinning it
to 1.0.0.0;


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!

cw

Jan 25 '06 #3

P: n/a
Glad it helped

Marc
Jan 25 '06 #4

P: n/a
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 1.0.0.0.

Does any alternative to UserControls exist?

Thanks in advance.

Jan 25 '06 #5

P: n/a
My stab-in-the-dark knowledge is exhausted here I'm afraid.

Marc
Jan 25 '06 #6

P: n/a
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

P: n/a
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.