Reference problems & custom controls disappearing

  • Thread starter Thread starter Suzanne
  • Start date Start date
S

Suzanne

Hi all,

I really hope someone out there can help me as I've been tearing my
hair out on this one for a good while and I'm getting really
frustrated now!

My problem is this - my custom controls periodically disappear from my
project when I build it. First of I get the message about a missing
dependency, then if I rebuild after that - the control just physically
disappears from the form, and I get an object not found error when I
run, (though sometimes when I rebuild the control can reappear)

My background - I'm working in a small team of developers, we are
using vb.net in visual studio with visual source safe.

As I've said I've been battling with this for a while and have done
some reading on this - I know that it is to do with references.
Therefore I am trying to do what all the Microsoft articles I've read
recommend with regard to references: - setting copy to local = true,
using project references not file references, and setting the build
order but to no avail. (Incidentally I still get this problem when
using file references).

Some more information - the custom controls are using a data access
object, and this data access object is also being used by another
object which the main form also uses. It is the reference to this data
access object that is the one that that I get the message about the
missing dependency.

Please help - now to add insult to injury - I can not now even re-add
my custom control from the toolbox. I can put it into the toolbox but
when I try to drag it from the toolbox on to the form on nothing
happens- not even a warning message.

Many thanks
Suzanne
 
Hi Suzanne,

The Windows Forms designer can indeed silently remove controls from a form.
This issue has been raised several times on these newsgroups (and I
experienced it myself just a week ago, see my REPRO post in the
microsoft.public.vsnet.ide newsgroup), but I am unaware whether there's a
patch or a workaround available. From my experience, before opening a form
with custom controls in the designer, ensure that:

a) The assembly with the controls has been successfully built
b) None of the controls throw an exception in their constructors (this also
causes the designer to remove the offending control from a form without a
word of warning)
c) No tasks like "You should rebuild ...." are on the Task List.

When a custom control still has been killed by the designer, open the form's
code view and examine the "Designer generated code" region. You'll most
likely see that the code creating and initializing the control is already
there, the designer has only removed code adding the custom control to the
container's (be it the form or a panel on a form) Controls collection. You
can manually restore the "status quo" and this should "resurrect" the
control.
 
Since you crossposted to .Net groups, I assume that this is a VB.Net question.... unless
the group contains the word "dotnet", it's not a .Net group. This is a VB "Classic" group.
If it were VB5 or 6, I'd say you have a Binary Compatibility issue.
 
Dmitriy Lapshin said:
Hi Suzanne,

The Windows Forms designer can indeed silently remove controls from a form.
This issue has been raised several times on these newsgroups (and I
experienced it myself just a week ago, see my REPRO post in the
microsoft.public.vsnet.ide newsgroup), but I am unaware whether there's a
patch or a workaround available. From my experience, before opening a form
with custom controls in the designer, ensure that:

a) The assembly with the controls has been successfully built
b) None of the controls throw an exception in their constructors (this also
causes the designer to remove the offending control from a form without a
word of warning)
c) No tasks like "You should rebuild ...." are on the Task List.

When a custom control still has been killed by the designer, open the form's
code view and examine the "Designer generated code" region. You'll most
likely see that the code creating and initializing the control is already
there, the designer has only removed code adding the custom control to the
container's (be it the form or a panel on a form) Controls collection. You
can manually restore the "status quo" and this should "resurrect" the
control.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Dimitry,

thanks so much for your prompt reply - I will certainly do what you
suggest and just add the code back into the controls collection when I
come across this problem in the future (as I'm sure I will!).

My biggest worry was that I was doing something wrong with the
referencing - but I just couldn't understand what.

Anyway thanks again
Suzanne
 
Ken

It's actually a Visual Studio .NET issue that seems to be language
independent. I would agree that the microsoft.public.vsnet.ide or
microsoft.public.vsnet.general group can be more suitable, but it's just
everybody more often or not just doesn't know where to start to look for the
root of the problem.
 
Dmitriy,

sorry to bug you again but I've yet again had the same problem:
I get the file or assemblies not found error and then my custom
controls disappear. I've tried doing what you suggested and manually
insert the code back into the designer generated region, but VSS just
won't accept it and disappears the code that I have just added back in
every time that I try to rebuild.

What I'd like to know is why am I getting the file or assembly not
found error in the first place if I'm using project references, copy
local = true etc?

Also I'm a bit unclear about how adding the custom control to the
toolbox fits into all this file vs project references debate? I
suppose that I'm actually referencing a specific version of the custom
controls dll by adding it into the toolbox in the first place? When I
drag it from the toolbox onto my form does that mean I am then
referencing that specific version (by a file reference) even though I
am including the custom control as a project reference in my solution?
Could that be why I'm getting that error message?

Any thoughts on this would really help me out
Thanks so much
Suzanne
 
[This followup was posted to microsoft.public.dotnet.framework and a
copy was sent to the cited author.]

x-code@no-spam- said:
Ken

It's actually a Visual Studio .NET issue that seems to be language
independent. I would agree that the microsoft.public.vsnet.ide or
microsoft.public.vsnet.general group can be more suitable, but it's just
everybody more often or not just doesn't know where to start to look for the
root of the problem.
I commend you for your help to Suzanne. Ken does not need to take a
fascist attitude, here.
 
Back
Top