473,385 Members | 1,379 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,385 software developers and data experts.

Any equivalent to debug.assert?

It would be very handy to be able to stop the debugger on parts of code
without having to explicitly set a breakpoint - either a "debugger.break" or
"debug.assert" type of thing would do. I've not come across anything, but is
there anything in (VB).NET that would allow me to do this?

TIA.
--
Brian Cryer
www.cryer.co.uk/brian
Apr 30 '07 #1
3 2074
re:
!is there anything in (VB).NET that would allow me to do this?

No, there isn't any native support for debug.assert,
but you can roll your own version quite easily, thanks to Dr. DotNetsky:

http://www.eggheadcafe.com/PrintSear...asp?LINKID=573

Compile the code in that page to an assembly, place the assembly in the
bin directory of your app, and add the Assert Handler to your app in Global.asax,
per the code supplied.

Voila! You have a debug.assert handler.

It will only fire in Debug mode and when running in localhost.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Brian Cryer" <br****@127.0.0.1.activesol.co.ukwrote in message
news:eK****************@TK2MSFTNGP02.phx.gbl...
It would be very handy to be able to stop the debugger on parts of code without having to
explicitly set a breakpoint - either a "debugger.break" or "debug.assert" type of thing would do.
I've not come across anything, but is there anything in (VB).NET that would allow me to do this?

TIA.
--
Brian Cryer
www.cryer.co.uk/brian


Apr 30 '07 #2
Thank you Juan.

This is great.

Since mostly I want to break on some of my exception handling I can probably
simply add:
If System.Diagnostics.Debugger.IsAttached Then
System.Diagnostics.Debugger.Break()
End If
but I wouldn't have found it except for you posting the link (and I'll
probably import it in full later). Thank you.
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:u1**************@TK2MSFTNGP04.phx.gbl...
re:
!is there anything in (VB).NET that would allow me to do this?

No, there isn't any native support for debug.assert,
but you can roll your own version quite easily, thanks to Dr. DotNetsky:

http://www.eggheadcafe.com/PrintSear...asp?LINKID=573

Compile the code in that page to an assembly, place the assembly in the
bin directory of your app, and add the Assert Handler to your app in
Global.asax,
per the code supplied.

Voila! You have a debug.assert handler.

It will only fire in Debug mode and when running in localhost.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Brian Cryer" <br****@127.0.0.1.activesol.co.ukwrote in message
news:eK****************@TK2MSFTNGP02.phx.gbl...
>It would be very handy to be able to stop the debugger on parts of code
without having to explicitly set a breakpoint - either a "debugger.break"
or "debug.assert" type of thing would do. I've not come across anything,
but is there anything in (VB).NET that would allow me to do this?

TIA.
--
Brian Cryer
www.cryer.co.uk/brian

Apr 30 '07 #3
google:

debug.assert asp.net
"Brian Cryer" <br****@127.0.0.1.activesol.co.ukwrote in message news:eK****************@TK2MSFTNGP02.phx.gbl...
It would be very handy to be able to stop the debugger on parts of code without having to explicitly set a breakpoint - either a
"debugger.break" or "debug.assert" type of thing would do. I've not come across anything, but is there anything in (VB).NET that
would allow me to do this?

TIA.
--
Brian Cryer
www.cryer.co.uk/brian


Apr 30 '07 #4

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

Similar topics

6
by: Alexander Malkis | last post by:
Why do programmers like to use NDEBUG instead of DEBUG? -- Best regards, Alex. PS. To email me, remove "loeschedies" from the email address given.
4
by: emma middlebrook | last post by:
I have a question regarding asserting ... here's some code: string GetAssertMessage() { ... prepare a message string and return it... } void SomeMethod() { ...
2
by: cody | last post by:
System.Diagnostics.Debug.Assert(); Hello??? A language should encourage programmers to heavily use the assert-feature, since it improves safety, stability, readability and maintainability of...
1
by: High and dRy | last post by:
Hello, I created a simple .NET C++ console application. And the Debug::Assert(false) statement is popping a message box in release version also. Any idea why ? Any complier settings I need to do...
7
by: Srinivasa Rao | last post by:
I have read in one article that when we compile the application in release mode, all the debug classes and properties will be automatically removed from the code. I tried to implement this thing by...
9
by: Bern McCarty | last post by:
I am porting stuff from MEC++ syntax to the new C++/CLI syntax. Something that we did in the old syntax that proved to be very valuable was to make sure that the finalizer would purposefully...
10
by: Peter Morris | last post by:
In Delphi I used to use Assert as a development aid. During debug it would ensure that certain conditions were met but in the Release build the Asserts were not compiled into the application. I...
1
by: =?Utf-8?B?am1hZ2FyYW0=?= | last post by:
Why does the call to Debug.AssertReferenceEquals not raise a UnitTesting exception but the call to Assert.IsTrue does? This inconsistency (Assert.ReferenceEquals returns a bool and Assert.IsTrue...
2
by: joelkeepup | last post by:
Hi, I made a change this morning and now im getting an error that says either "a is undefined or null" or "e is undefined or null" the microsoft ajax line is below, I have no idea how to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.