VS2005 Winforms Designer Exception Screen and IE8 - winforms

It seems since I installed Internet Explorer V8 that my Winforms Designer Exception screen (WSOD) is broken. Where before I would get red text with the error described, today I get this:
WSOD Broken http://faxt.com/images/WSODBroken.png
Can anyone suggest to me a way to recover the text view of this display, I'm wasting time trying to read the reason the Winform file won't display in the designer now.
Thank-you.

I was able to fix this by adding a new subkey to the registry for .tmp and copying settings from .html. After these changes have been made, designer errors in Visual Studio should be rendered instead of displaying the HTML code for the error.
Open HKEY_LOCAL_MACHINE\SOFTWARE\Classes and add a new subkey of type .tmp.
Change the data of the (Default) value to: htmlfile
Add a new string value of Content Type with data of text/html
Add a new string value of PerceivedType with data of text
(source: lazypenguin.com)

The problem with that fix (adding a subkey) is that now all tmp files are treated as HTML files. I found that if you are getting it trying to download the tmp file (instead of just displaying it incorrectly), the best fix is to remove the .tmp entry from the registry (and tmp_auto_file) at "HKEY_LOCAL_MACHINE\SOFTWARE\Classes" or "HKEY_CLASSES_ROOT" as they are actually the same place. It may, however, still display as text instead of a web page.

The problem actually is "The class Form1 can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try loading the designer again. "
So I've moved Form1 class in the beginning of the file (I've created several classes before it manually) - it works! Don't do anything with IE.

Related

Why would a .g.vb file for a WPF form not be generated in Visual Studio 2019?

I have a form in a WPF application that is generating an error message:
"BC30451: 'InitializeComponent()'is not declared. It may be inaccessible due to its protection level"
InitializeComponent() is a function that is generated in the .G.VB file associated with a XAML file. If the .G.VB is not generated, there is no InitialzeComponent() function.
The steps that I have taken thus far are:
Compare the properties of the XAML file that is not generating a .G.VB to the properties of a XAML file that is producing a .G.VB file.
I tried a Build | Clean Solution; followed by a Build | Rebuild Solution.
Made sure that the namespace and class are the same in the VB and XAML x:Class.
Closed and re-started Visual Studio 2019.
Added a InitializeComponent() function to the class.
This will need to be documented so we know that this is typically automatically generated. Doing this leaves the code vulnerable to future changes made in the designer.
The properties for the XAML file are set as:
Build Action: Page
Copy to Output Directory: Do not copyist item
Custom Tool: XamlIntelliSenseFileGenerator
My questions are:
What prevents the .G.VB file from being automatically generated?
What is the best resource to diagnose the cause of this issue?
Additional Information
I added a partial class with an InitializeComponent() method. This function calls LoadComponent( uriLocator ) that loads the XAML referenced by the uriLocator string. This addresses the undefined InitializeComponent()... error in the short-term to get further information to identify the root cause.
Note that adding your own InitializeComponent() should not be seen as a solution. It should only be used as a stepping-stone to find out why the .G.CS or .G.VB files are not being generated. The problem is that a custom G.CS or G.VB must be updated manually with any change to the XAML.

Changed label text on form, designer shows new text, running program shows old text

I change the text property of labels on a windows form. The form displays the correct new labels when displayed in the VS 2010 forms designer. I also change the color of the font.
When I run the program, the window displays the old text values instead of the new text values. The form displays the new font color on the labels.
There seems to be no occurrences of the old text value in the source code. Where is the old text value still hiding?
I clean the solution and rebuild it, but nothing changes.
A colleague observed that this is an artifact of converting projects from VS2005 to vs2008 to VS2010 and suggested a "brute force" corrective measure.
It actually worked.
1) Create a new blank form in the project.
2) In the original form, using the forms designer "Edit" menu, use the "select all" and "copy" actions. This copies all forms objects into the clipboard.
3) Paste the clipboard into the blank form.
4) Copy (most of) the program code from the old form into the new form, excluding anything generated by the forms designer.
5) Delete the old form from the project. Make changes as necessary to use the new form
Not very elegant, but good for meeting a deadline.
Thank you J.H!
Epilog:
"Brian" and "Blogbeard" both had the right direction in suggesting a hidden resource file.
Early in the execution of the code lay a method call to an obscure subsystem that no one knew anything about. That subsystem turned out to be a defunct language translation module which was supposed to translate all of the labels in a form from a native language to a target language.
It was configured to keep the original labels and their translations in a file outside the scope of the IDE. Changes in the form itself were completely ignored if the translator found the label name in its file.
Moving the form contents to another package effectively disabled the translator.
The elegant solution turned out to a three-line change that removed the method call to the translator. (it was no longer required in the application)

Copy pasting WPF window gives error

I realized that VS gives error when we try to copy paste one of the window. The errors are usually of type the method call is ambiguous between InitializeComponet() or other methods. This is because that VS only renames xaml files but not the assciated CS files. I dont know why VS dont handle that. What is better way to copy paste the existing windows, that will not give any error. Or is their any simple workaround? What all other things we need to manually rename?
The VS renames XAML and the associated CS files as well. What it does not do is change the class name and constructor name in the CS file and the x:Class property in the XAML file. If you change these, this would work fine.
I don't think there is a workaround, but I don't think that it is a lot of work either.

Microsoft Access error: "Because of your security settings and current security policy, this control is disabled"

I am getting an issue with a access 2007 application that I am working on. Access acts as a front end for a SQL server 2005 backend. When I try to click on a richtext control on the form, it gives me the following error:
Because of your security settings and current security policy, this
control is disabled. To modify your policy and enable the database,
use the message bar.
After a bit of searching, the suggestiong is to add a trusted location, however this error still comes up.
Ok so I found out the cause of this issue after a lot of trial and error. It seems that the rich text box control has limited support in Access 2007. I found out that the rich text box I am using is Microsoft Microsoft Rich Textbox Control 6.0 (SP4) - RichTX32.OCX. Apparently it will cause the above error if activeX is disabled.
To fix this I modified my registry entries as follows (although this opens up security issues with IE aswell):
Open up regedit
Go to the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility{3B7C8860- D78F-101B-B9B5-04021C009402}
There should be a DWORD called Compatiblity Flags. Set this to 0 (default is hexadecimal 400)
Some additional information that I found useful follows:
http://support.microsoft.com/kb/838010
http://p2p.wrox.com/access/10416-rich-text-box-controls-access-2003-a.html
I recently found this ?, and started updating the control to work. Then, I came across the right way to get rich text in a form in MSO 2007+:
Insert or add a rich text field
It says you need to have a memo field in a table, and set its text format to Rich Text. Since the solution is a bit opaque, I'll continue with what worked for me: I then go into form design, and create a text field. I set its data source to the table's rich text memo field; and its "Text Format" property to "Rich Text". I set its "Scroll Bars" property to "Vertical".
Now, I get some nice text formatting options in Access 2010; but it's kinda stupid the way they've implemented them. There's no format painter. Also, if I want to e.g. set the font to Times New Roman to pitch 11, it doesn't let me; but makes turns it into 10; although I can select 12 also - but not 11. If, however, in Design View, I set it the field's font to "Times New Roman", and set the font size THERE to 11, the font is size 11 by default. I can paste things into it in 11 pitch, by first pasting them into Notepad, to strip them of their formatting attributes, and then from Notepad into my field, to get pitch 11 text; or I can paste pitch 11 from elsewhere.
This has the advantage of getting some handy text formatting controls to light up on your home ribbon, and lets you format stuff more or less properly.

Generating output in a Windows Form App

I am working on a windows form app like most development it is usually useful to see output. I am wondering what methods you use to see output in a windows form app.
PS. I am new to visual studio in general.
You can set some Labels around and display text on them:
Label.Text = "Some Text";
And DataGridView controls for information from tables, and for a better insight, you can set breakpoints in your code by clicking the far-left part of your code editing area. When the program reaches to that point it'll stop and you can hover your variables and objects for a better view of their insides...
Oh, and also VS has a "Locals" window when you run your project, that shows all the objects and variables being used and some information about them.
the user interface (a grid or other
controls on a form)
a report (like Crystal)
a file (.txt)
a database table updated

Resources