Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Emitting design-time messages / warnings
 

Emitting design-time messages / warnings

Is it possible to programmatically emit warnings or messages into the "Error List" window of Visual Studio (2008) ? I would like to create a custom control that would warn the developer in the Forms Designer when he does something he's not supposed to do. I tried throwing execeptions but that will prevent the developer from designing the form if the control already is in inconsistent state.
Michal Burger  Monday, July 20, 2009 2:03 PM
Hi Michal,

It's the hosted compiler that emit errors or warnings to the Error List within Visual Studio. I'm afraid we have no way to emit errors or warnings by ourselves.
Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Wednesday, July 29, 2009 8:40 AM

If you want anything to appear in the Output window, it has to come from stdout. To do this, your app needs to be linked as a "console" app. Set the /SUBSYSTEM:CONSOLE flag in the project's property page, under Linker/System set the SubSystem property to CONSOLE.

Once you have your output in the window, if you include the text "Error:" it will appear as an error, or if you set "Warning:" it will appear as a warning. If your error text begins with a path/filename, followed by a line number in parenthesis, the IDE will recognize it as a "clickable" error, and navigate you automatically to the faulting line.


MCAD - MCSD MCTS Sharepoint 2007 MCTS SQL Server 2005 http://blog.raffaeu.com "If my answer is useful remember to mark it as useful".
raffaeu_bermuda  Monday, July 20, 2009 4:50 PM
Thank you for your reply. I'm afraid that this either doesn't work for me or I'm doing something wrong.

First of all maybe I should clarify that I'm talking about the Visual Basic IDE. There's a window called "Error List" where all the errors / warnings / messages appear, as far as I know this is different from the "Output" window where goes the output from stdout. But anyway if it shows up anywhere it will be good enough for me. Unfortunately, I can't make the text go to the output during design time, it will show up there when the application actually runs but not during design time (i.e. in the Forms Designer). Also when the application stops, the text stays in the Output window but it doesn't seem to be clickable. (There are no errors in the "Error List" window.) The text I'm printing is "Error:C:\Test.vb(10)". Any ideas?
Michal Burger  Monday, July 20, 2009 9:14 PM
Hi Michal,

It's the hosted compiler that emit errors or warnings to the Error List within Visual Studio. I'm afraid we have no way to emit errors or warnings by ourselves.
Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Wednesday, July 29, 2009 8:40 AM
Thank you Linda. I hoped there would be some way to make this work, looks like I'll have to stick to throwing exceptions.
Michal Burger  Friday, July 31, 2009 9:04 AM

You can use google to search for other answers

Custom Search

More Threads

• Referenced Project controls not in Toolbox?
• Menu item with an Icon to the left.
• Problem with StatusStrip and ToolStrip
• How to find which child form is active during application closed
• Feature rich .NET ComboBox control released!
• Want help in TImer in C#.Net 2005.
• File signing in .NET
• Mouse Cursor on UserControl in Design Mode
• Nested InstanceDescriptors
• how to know that a user control is in design mode