473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Usercontrol changes doesn't compile?

I've got a usercontrol derived from a normal ComboBox that contains some
special formatting code. On my main form I've got a lot of my custom
comboboxes.

I discovered a bug in the derived control and fixed it. But it still doesn't
work for the controls already added to the form. It works fine for new
instances of the control dragged from the toolbox to the form.

I don't want to have to drag and drop new controls to exchange all my old
controls - that is a sure way to introduce errors...

No matter what I do, I cannot update the old controls. I've tried changing
them in the designer file to regular ComboBoxes and back to my derived
combobox - Doesn't work.

I've tried removing the reference to the project in which the component is
located and readding it - Doesn't work. I've tried adding the new code
alongside the old code under a different classname and renaming the old
controls' class to the new controls' class in the designer file - Doesn't
work.

I'm lost now - have no more ideas! Why the h*** does it have to be that
hard?

/Johnny J.
Aug 7 '07 #1
6 1912
On Tue, 07 Aug 2007 18:00:48 +0200, Johnny Jörgensen <jo**@altcom.sewrote:
I've got a usercontrol derived from a normal ComboBox that contains some
special formatting code. On my main form I've got a lot of my custom
comboboxes.

I discovered a bug in the derived control and fixed it. But it still doesn't
work for the controls already added to the form. It works fine for new
instances of the control dragged from the toolbox to the form.

I don't want to have to drag and drop new controls to exchange all my old
controls - that is a sure way to introduce errors...

No matter what I do, I cannot update the old controls. I've tried changing
them in the designer file to regular ComboBoxes and back to my derived
combobox - Doesn't work.

I've tried removing the reference to the project in which the component is
located and readding it - Doesn't work. I've tried adding the new code
alongside the old code under a different classname and renaming the old
controls' class to the new controls' class in the designer file - Doesn't
work.

I'm lost now - have no more ideas! Why the h*** does it have to be that
hard?

/Johnny J.
Hi Johnny,

How are the Form and the UserControl related? Are they in the same project? If so, usually a recompile should be sufficient, though you may need to close and reopen the designer view to have it update itself. If you are referensing an external assembly make sure the referense is updated. Check if the new assembly is copied locally if needed, and maybe delete and recreate the referense.

--
Happy coding!
Morten Wennevik [C# MVP]
Aug 7 '07 #2
Johnny Jörgensen wrote:
[...]
No matter what I do, I cannot update the old controls. I've tried changing
them in the designer file to regular ComboBoxes and back to my derived
combobox - Doesn't work.

I've tried removing the reference to the project in which the component is
located and readding it - Doesn't work. I've tried adding the new code
alongside the old code under a different classname and renaming the old
controls' class to the new controls' class in the designer file - Doesn't
work.

I'm lost now - have no more ideas! Why the h*** does it have to be that
hard?
How hard it is to fix a bug after the fact depends somewhat on in what
way you screwed up the code creating the bug in the first place.

You don't describe the bug, but if it's simply an implementation bug,
then as Morten say, recompiling the custom control's assembly should fix
the issue in any code that references it. Exceptions to this would be
if you have done something extra, like copying the custom control's
assembly somewhere else where you then referenced it in the using
application, or if the bug was related to some defaults for the control
that then got codified in an InitializeComponent() method somewhere.

Pete
Aug 7 '07 #3

"Morten Wennevik [C# MVP]" <Mo************@hotmail.comwrote in message
news:op.two6rjdrdj93y5@stone...
On Tue, 07 Aug 2007 18:00:48 +0200, Johnny Jörgensen <jo**@altcom.se>
wrote:
>I've got a usercontrol derived from a normal ComboBox that contains some
special formatting code. On my main form I've got a lot of my custom
comboboxes.

I discovered a bug in the derived control and fixed it. But it still
doesn't
work for the controls already added to the form. It works fine for new
instances of the control dragged from the toolbox to the form.

I don't want to have to drag and drop new controls to exchange all my old
controls - that is a sure way to introduce errors...

No matter what I do, I cannot update the old controls. I've tried
changing
them in the designer file to regular ComboBoxes and back to my derived
combobox - Doesn't work.

I've tried removing the reference to the project in which the component
is
located and readding it - Doesn't work. I've tried adding the new code
alongside the old code under a different classname and renaming the old
controls' class to the new controls' class in the designer file - Doesn't
work.

I'm lost now - have no more ideas! Why the h*** does it have to be that
hard?

/Johnny J.

Hi Johnny,

How are the Form and the UserControl related? Are they in the same
project? If so, usually a recompile should be sufficient, though you may
need to close and reopen the designer view to have it update itself. If
you are referensing an external assembly make sure the referense is
updated. Check if the new assembly is copied locally if needed, and maybe
delete and recreate the referense.

--
Happy coding!
Morten Wennevik [C# MVP]
The form is in one project and the control in another, but in the same
solution. The control project is of course referenced in the form project.

Recompiling doesn't help - nor does it help removing the reference and
adding it again.

The fact that a new instance of the control added to the form behaves
perfectly seems to me to indicate that the build and reference for the
control is ok. But it doesn't explain why "old" instances of the control are
not updated. I can have the same type of controls on the same form that
behave in two different ways.

It's VERY strange, and I've never had any problems with custom and user
controls not updating before.

Cheers,
Johnny J.
Aug 8 '07 #4

"Peter Duniho" <Np*********@NnOwSlPiAnMk.comwrote in message
news:13*************@corp.supernews.com...
Johnny Jörgensen wrote:
>[...]
No matter what I do, I cannot update the old controls. I've tried
changing them in the designer file to regular ComboBoxes and back to my
derived combobox - Doesn't work.

I've tried removing the reference to the project in which the component
is located and readding it - Doesn't work. I've tried adding the new code
alongside the old code under a different classname and renaming the old
controls' class to the new controls' class in the designer file - Doesn't
work.

I'm lost now - have no more ideas! Why the h*** does it have to be that
hard?

How hard it is to fix a bug after the fact depends somewhat on in what way
you screwed up the code creating the bug in the first place.

You don't describe the bug, but if it's simply an implementation bug, then
as Morten say, recompiling the custom control's assembly should fix the
issue in any code that references it. Exceptions to this would be if you
have done something extra, like copying the custom control's assembly
somewhere else where you then referenced it in the using application, or
if the bug was related to some defaults for the control that then got
codified in an InitializeComponent() method somewhere.

Pete
Thanks for the vore of confidence Pete. First of all: The fact that new
instances of the control behaves correctly should be a good indicator that
the code is not screwed up. That is also why I don't describe the behaviour
in more detail - it seems irrelevant when I can see that the new control
instances behave correctly.

But if you'd like: The changes in the control are in the paint routines. As
mentioned, it's an inherited combobox. Before I took care of the entire
painting of the control in both enabled and disabled state. I got another
unexplainable bug in the control when the control was enabled: If you
CLICKED on the combobox to show the drop down list, everything was ok, and
the blue highlighting was only applied to the actual highlighted item. But
if you TABBED your way to the same control and pressed the down arrow, ALL
items in ALL of my inherited comboboxes on the entire form (not only the
focused one) became blue highlighted.

Seeing that the changes the customer wants are only with regards to the
disabled look, I thought: Why not just ownerdraw the control when it's
disabled and let windows handle the drawing when it's enabled. So in the
EnabledChanged routine, now, I simply switch to and from ownerdrawing.

That works perfectly in my test application and even in my real application
when a NEW instance of the new control is put on the form, but the "old"
instances behave in a strange way: Everything's ok when the control is
disabled, and when the control is enabled, it is painted correctly, but when
you drop the list, there is NO highlighting and NO item texts. There is a
scrollbar as if the items were there, but you can't see their texts.

The controls are all databound. I tried adding a new instance of the control
to the form and copy the databindings from one of the old instances. When
run, the new control shows the items correctly, but the old control doesn't
show any items att all (only the scrollbar).

I could fix the whole problem by exchanging all of the old instances with
new instances by dragging and dropping controls, renaming and setting
properties all over, but seeing that I have around 50 of the controltype on
one form only and that the control otherwise appears on other forms in the
project, It would be a tremendous task.

And anyway, all the old controls shold in my experience behave as the new
instances after building, but they don't!

/Johnny J.
Aug 8 '07 #5
Johnny Jörgensen wrote:
Thanks for the vore of confidence Pete. First of all: The fact that new
instances of the control behaves correctly should be a good indicator that
the code is not screwed up.
You misunderstand. By "screwed up" I am referring to the bug you fixed
in the first place. IMHO, the word "bug" necessarily implies that "the
code is screwed up". If the code wasn't screwed up, there wouldn't be a
bug.

I still don't know why your control isn't being updated, but I strongly
suspect that you've got an extra copy of the previous assembly sitting
around somewhere that's being used, with the reference to the new
assembly only being used when you drag a new instance of the control
onto your form.

So the first thing I'd do is do a disk search for that assembly, and see
if I can find any other copies somewhere.

This is a little over my head, but I gather that .NET actually caches
some assemblies so one thing you might want to look into is whether that
cache is somehow involved.

Pete
Aug 8 '07 #6
Johnny Jörgensen wrote:
>I still don't know why your control isn't being updated, but I strongly
suspect that you've got an extra copy of the previous assembly sitting
around somewhere that's being used, with the reference to the new assembly
only being used when you drag a new instance of the control onto your
form.

But then surely I should have two references visible in my project?
That seems like a reasonable assumption, but since it seems like a
reasonable assumption that fixing the bug in the original component
would propagate to existing instances of the component in existing code,
and since that reasonable assumption is obviously false, you need to
forget about reasonable assumptions and start from scratch.

You've got a situation that should not be happening. At least in my
experience, VS and .NET are reasonably bug-free, and at the very least
for you to run into something like this, something has happened that is
more complicated than you have a reference to a component, changing the
component, and the behavior of that component not changing in the
already-referenced instances.

The "instance" of the component in your existing code is just code using
the public API of your component to instantiate the component at
run-time. It's not like the implementation of that component is somehow
incorporated into the referencing code. So, either there's something
about the public API used in the instantiation you haven't mentioned, or
there's something you've done that's different from the usual mechanism
of referencing that has led to the previously-compiled assembly still
being around and still being used.

Which of those situations is the case, I don't know. You seem to be
implying that the former is not a possibility, which leaves us with the
latter. Since I have never run into this particular problem, in spite
of having several .NET projects that refer to other .NET projects, and
in spite of being able to make changes to the referenced projects and
having those changes appear in the referring projects, I can't offer
specific advice about what might wrong.

But I can confirm that normally this just works fine. The logical
conclusion is that you've done something that's not normal. Perhaps not
on purpose, and perhaps not even with you realizing it. But regardless,
to fix it you'll either have to go with the work-around you know works
(replacing existing instances with new instances), or you need to
abandon any reasonable assumptions you have about how this _should_ work
and consider all the possibilities of how it _is_ working, even when
that seems like it involves unreasonable assumptions.

Pete
Aug 8 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: babylon | last post by:
I created a class which inherits from UserControl.. However, I can't find it in the "My User Controls" tab in designer view... How can i add it back myself? thx...
4
by: james | last post by:
I cannot get my UserControl's browsable properties to show up in the designer properties panel. I have then public virtual bool TestProp { {get return testProp; } set { testProp = value; } } ...
6
by: steve bull | last post by:
I created a usercontrol class, RGBColorSpace, which is derived from an abstract class, ColorSpace, but when I try to click on the design panel for the control I get an error message "Unable to...
3
by: Alessandro Rossi | last post by:
Hi I developed a usercontrol with a textbox and an htmlInputHidden When I add my usercontrol in a webform, it works properly If I add my control in a template column of a datagrid i have some...
2
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation...
1
by: Will Gillen | last post by:
I know this has probably been asked before, but I can't seem to find a solid answer in any of the archives. First, before my question, please forgive my limited knowledge of the event lifecycle...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
3
by: Don | last post by:
I've created a custom UserControlwithin which I have placed a Panel. I've changed the Panel's "Modifier" property to Public so that it appears in the Properties Window of the UserControl. This...
5
by: Pieter | last post by:
Hi, I'm getting a really terrible and anoying bug/problem in VS.NET 2005: 1. Create a new Windows Application. 2. Add a new class Class1. 3. Add a usercontrol UserControl1. 4. Add a public...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.