 |
|
 |
I don't even get a WSOD. Well... it is white. But all I have seen since reinstalling Visual Studio 2005 (fresh) on my fresh install of Windows 7 is a single line of HTML code. (AND YES... I did download the Service Packs and Vista/7 updates!). It doesn't even seem to be reading it as a web page but as simple text. I spent 4-5 hours fixing a problem with a form because I forgot that the WSOD actually does give a clue the problem at least. But I didn't even see the error amongst all the HTML formatting code.
In an attempt to avoid another 4-5 hour of complete frustration I read the line very carefully and suddenly remembered that the HTML is supposed to be rendered as the WSOD and tell you something about the problem. So I searched online for a way to get the WSOD to display correctly to no avail. But I did find this article. Does anyone know how to get Visual studio render the WSOD page correctly?
Honestly... I hate VS 2005. Every time I install it I get a different bug where it is supposed to do something and doesn't. Why? The particular issue worked right the last time I installed it!!!
Meanwhile... I guess I will follow this procedure to find the problem. Thanks!
|
|
|
|
 |
|
 |
Get the process ID of the VS instance you want to be the debugEE, before opening a 2nd (or 3rd or 4th...) instance of VS to be the debugER.
|
|
|
|
 |
|
 |
I have come across a number of WSODs that were not solved by the solutions shown here.
Even the test to see if you are running in the IDE (looking at the process name) did not solve it.
I finally discovered why that's so.
In my case, code that is jitt'ed in the IDE was referencing types from a DLL that could not be loaded into Visual Studio. So, the solution to the problem was't preventing code from executing in the IDE, the solution was to prevent code from being jitted in the IDE. The IDE will jit all code that is called from a constructor, on a per-method basis.
Hence, if you have a test that checks to see if you are running in the IDE and the tests indicates you are not, and call code like this:
public class MyControlClass : UserControl
{
public MyControlClass()
{
if( ! IsVisualStudio() )
{
Foo foo = new Foo(); }
}
}
In the above, the IsVisualStudio() method returns true if you are running in the IDE (by looking at the current process name), and the Foo instance is not created when you are in the IDE.
Even though the the Foo type is not instantiated at design time, the code for the entire method is jitted, and that's what causes the WSOD.
The solution is to put any code that references types which cannot be jitted at design time in a seperate method, and then call that method via reflection. You have to call the method via reflection because if you call it directly from the constructor, it will be jitted as well.
public class MyControlClass : UserControl
{
public MyControlClass()
{
if( ! IsVisualStudio() )
{
MethodInfo m = this.GetType().GetMethod("runtimeOnly", BindingFlags.Instance|BindingFlags.NonPublic)
m.Invoke( this, null );
}
}
void runtimeOnly()
{
Foo foo = new Foo();
}
}
HTH
|
|
|
|
 |
|
 |
Thanks! I had this problem in a WPF application. Your method can be used with WPF apps too.
|
|
|
|
 |
|
 |
Thanks for your reply, it's great to know this article is still useful despite the evolution in technology.
|
|
|
|
 |
|
 |
Hi ,
when am trying to open designer view for a form which is inheriting BaseViewForm getting white screen with this message:
One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.
Could not load file or assembly 'Wrappers.CLI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Hide
at MYnamespace.BaseViewForm..ctor()
Observatrions:
1. In C# project I added a reference to Wrappers.CLI.dll( This Project VC++ project Wrapper one which makes contact from C# code to c++ code)
Wrappers.CLI version is 1.0.0.1 but when I added reference to this the VS shows the version as 0.0.0.0 (By looking at properties after adding reference)
So suspected the variables from Wrappers.CLI.dll which declared in C# form (which is being opened in design view) may cause the error.
2. I created another BaseViewFormNew without having code related to Wrappers.CLI.dll and made to use this Base form instead of earlier BaseViewForm (which contains code related to Wrappers.CLI.dll then this forms gets opened. This approach worked fine. Then once anyof the forms design view is opened am reverting abck to inherit using older BAseViewForm then surprisingly the design view is getting opened . But this works in one machine in other machines this is not working. So what would be the solutions? No idea.
I tried
1. rebuilding, Clean and rebuilding, deleting bin,obj files
2. steps in http://www.codeproject.com/KB/cs/wsod.aspx
3. Deleting cache fiels from Project Assemblies folder
but none was working..
Thanks,
Ramki
|
|
|
|
 |
|
 |
Hi,
Am getting the problem while viewing the designer of the
windows form (developed in C#)
C# project has references to wrapper classes(to contact with C++
classes).
Error :
One or more errors encountered while loading the designer. The errors
are listed below. Some errors can be fixed by rebuilding your project,
while others may require code changes.
Could not load file or assembly Wrappers.CLI, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies. The
system cannot find the file specified.
Hide
at BaseClass..ctor()
The reference had been added through project browse folder only.
I tried using the steps given in the article but could not get the exact line of code where it was giving this exception.
Thanks,
Ramki
|
|
|
|
 |
|
 |
Use Debug.Assert either in a catch clause or as a conditional statement The assertion works even in design mode. try { } catch(Exception err) { Debug.Assert(false,err.Message); } or Debug.Assert(text != null,"The text is noll"); Natza Mitzi
|
|
|
|
 |
|
 |
Thanks for this tip, Natza. I tried what the OP suggested but I couldn't work out how to set this bit:
"Set Visual Studio to break on Common Language Runtime exceptions - Thrown and User-handled"
but your suggestion worked a treat and has saved me hours of head-scratching and teeth-gnashing.
SH
|
|
|
|
 |
|
 |
Hi, thanks for good article!
But, there is littlebite mistake.
The body of DesignMode property looks like this:
protected bool DesignMode {
get {
bool result = false;
ISite site = this.Site;
if ( site != null ){
result = site.DesignMode;
}
return result;
}
}
What it mean? The DesignMode property in constructor always returns False!
------
There is next tricky question.
If you have this classes:
MyTextBox // derives from TextBox
MyUserControl // derives from UserControl and contains one or more controls "MyTextBox"
MainForm // derives from Form and contains one or more controls "MyUserControl"
The Visual Studio Designer sets the Site property only to controls added in designed control/form, but not to controls inside. So, if you open the designer for MainForm the instances of MyUserControls will have the DesignMode set to True bud the instances of MyTextBox will have the DesignMode always set to False.
The solution is the helper class with simple method IsInDesignMode which looks like this:
public static class MyHelperClass {
public static bool IsInDesignMode( Control control ) {
if ( control == null ) { throw new ArgumentNullException( "control" );
bool result = false; Control ctl = control; do {
ISite site = ctl.Site; if ( site != null ) {
result = site.DesignMode; if ( result ) { break; } }
} while ( ( ctl = ctl.Parent ) != null );
return result;
}
}
Then the using in the custom/user control should looks like this:
public class MyTextBox : TextBox {
public MyTextBox() {
...
}
protected override void OnLoad( EventArgs e ) {
base.OnLoad( e );
if ( MyHelperClass.IsInDesignMode( this ) == false ) {
}
}
}
/* Geniality is in simplicity. */
|
|
|
|
 |
|
 |
That works great!
Wanna know why VS guys still don't fix this even in VS2008!
Thanks!
|
|
|
|
 |
|
 |
It's worth mentioning that this behaviour is a 'feature' of VS2005, VS2003 didn't do it, and when reported as a bug, MS reported this was a new feature. I actually have forms that give the WSOD, and don't throw an exception when attaching a second instance, so it can go a little deeper, but your article will help a lot of people who are stuck on this Microsoft insanity.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
 |
|
 |
Hi Christian,
I appreciate your feedback!
Nadav
|
|
|
|
 |
|
 |
Christian,
I have in fact a form giving WSOD and not throwing exception when attaching a second instance. This is a VB project imported from VS 2003. What can I do?
Thanks
Leonardo Presciuttini
|
|
|
|
 |
|
 |
First step is to look at your load event and start commenting things out, until you find the line that causes the problem. The DesignMode property can be used to make the designer skip lines.
I've posted on the MS forums about my problem and no-one from MS replied, so I was unable to solve my problem, I just live with it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
 |
|
 |
In effect my routine at load event contains references to objects which are initialized outside of it. But putting 'exit sub' at the beginning has given no result: all runs as before. Moreover, other forms of mine, which have no load event routine give the same error. But in their case it is sufficient to display the associated resource file (after showing all project files) for the error to disappear. This is not sufficient for the form with load event.
ANy
Leonardo Presciuttini
|
|
|
|
 |
|
 |
Hello,
I'm getting the same errors but for a different reson.
I have a class that inherit an activex. now i made that class as a singleton because i want everybody to have an access to it.
it is working fine but in design time i can't see the page were the control is in it. (I get an error)
my initialization in the designer is like that:
myactivex = ClsActivex.Instance();
In the instance i make the new ClsActivex.
any idea whan can i do to avoid the error?! (i don't care that i wouldn't see the control in design time.
Regarts, Lin.
|
|
|
|
 |
|
|
 |
|
 |
Great artical! However, we prefer to call this screen the "Pink screen of Pleasure"
|
|
|
|
 |
|
 |
Thanks
WSOD's do indeed bring many many hours of quality time for GUI developers
|
|
|
|
 |
|
 |
I have a sub-class of UserControl that populates a TreeView from a database. This is done in the constructor. I use
if (this.DesignMode)
return;
to avoid reading from the database in design mode since the connection information is not available at this time. This works fine when designing the UserControl.
However, when I add the UserControl to a Form I get the "WSOD". It seems that InDesignMode is only set to true when the UserControl itself is opened in the designer.
What I tried is to wrap the code that reads from the database in a try-catch block and ignore any Exception thrown. I do not understand why the Exception that is thrown within the try-block is not caught. Does anyone have a suggestion how to handle this.
Daniel
|
|
|
|
 |
|
 |
See my comments below.
If your control that is being designed was
created with "Add Inherited User Control",
you can rely on DesignMode from the class
that you are deriving from.
The simple solution for me was to just look
at the name of the current process, and see
if it was 'devenv'.
|
|
|
|
 |
|
 |
Thanks a lot. That was the solution I was looking for.
Daniel
|
|
|
|
 |
|
 |
I usually just do:
public SevenHolder()
{
InitializeComponent();
if ( DesignMode )
return;
// now, put all my custom code here with no other checks for running instance or singleton...
}
-- modified at 2:28 Tuesday 28th March, 2006
|
|
|
|
 |
|
 |
Of course. That's my "second approach".
My personal coding style (that probably came from coding C/C++ for a long time), is that each and every possible point of failure should be checked. Perhaps somebody has a bug in the singleton? After all it could be someone else's code.
Nadav
|
|
|
|
 |