473,941 Members | 13,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

turn off assertions in VB 2005


Say I would like to use assertions to make sure correct inputs are
given to a procedure. But, I want to do this in testing only, not in
production.

I saw Debug.Assert, which is nice, but does VB.NET have a feature where
you can turn off assertions on production code?

--
http://www.douglass.com

Oct 28 '06 #1
4 1679
Douglass,

Debug methods are not included in the Release build.

Kerry Moorman
"do************ @earthlink.net" wrote:
>
Say I would like to use assertions to make sure correct inputs are
given to a procedure. But, I want to do this in testing only, not in
production.

I saw Debug.Assert, which is nice, but does VB.NET have a feature where
you can turn off assertions on production code?

--
http://www.douglass.com

Oct 28 '06 #2
ok... thanks. would be a nice feature.

--
http://www.douglassdavis.com

Kerry Moorman wrote:
Douglass,

Debug methods are not included in the Release build.

Kerry Moorman
"do************ @earthlink.net" wrote:

Say I would like to use assertions to make sure correct inputs are
given to a procedure. But, I want to do this in testing only, not in
production.

I saw Debug.Assert, which is nice, but does VB.NET have a feature where
you can turn off assertions on production code?

--
http://www.douglass.com
Oct 28 '06 #3
You can also use your own build types:

Goto the menu Build - Configuration Manager, and select <newunder
Active Configuration. Type you config name (ie MyTest), and copy the
settings from Release.

Now you can use the following in your code:

#IF CONFIG = "MyTest" THEN
your asserting code
#END IF

The above code is only compiled in your application when you are using
the MyTest configuration; as soon as you switch to Release, the code is
removed from your assembly.
do************@ earthlink.net wrote:
Say I would like to use assertions to make sure correct inputs are
given to a procedure. But, I want to do this in testing only, not in
production.

I saw Debug.Assert, which is nice, but does VB.NET have a feature where
you can turn off assertions on production code?

--
http://www.douglass.com
Oct 29 '06 #4
As Kerry stated,
>Debug methods are not included in the Release build.
When you compile your app you can compile it for Debug or for Release.

The default is a Debug build, so Debug.Assert will be included.

You can use "Build - Configuration Manager - Active solution configuration"
to switch between Debug & Release builds of your application.

Alternatively there should be a "Solution configurations" combo box on the
standard toolbar.

NOTE: You may need to use "Tools - Options - Projects and Solutions - Show
advanced build configurations" to enable the solution configurations above.

As Theo suggests you can also use Build - Configuration Manager to define
new configurations, however for Debug.Assert this is not specifically
necessary.

--
Hope this helps
Jay B. Harlow
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
<do************ @earthlink.netw rote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
ok... thanks. would be a nice feature.

--
http://www.douglassdavis.com

Kerry Moorman wrote:
>Douglass,

Debug methods are not included in the Release build.

Kerry Moorman
"do*********** *@earthlink.net " wrote:
>
Say I would like to use assertions to make sure correct inputs are
given to a procedure. But, I want to do this in testing only, not in
production.

I saw Debug.Assert, which is nice, but does VB.NET have a feature where
you can turn off assertions on production code?

--
http://www.douglass.com

Oct 29 '06 #5

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

Similar topics

0
290
by: P. Chalin | last post by:
If you make use of assertions (e.g. assert statements) in your code, I would like to invite you to participate in a 15 min survey on program assertions. In this survey we seek your opinion concerning the issue of errors/exceptions raised during assertion evaluation. The questionnaire is available here: https://www.dsrg.org/ASN_Survey/wnd.html Thank-you in advance, P.Chalin
10
1977
by: Al Christoph | last post by:
Please forgive me if this is the wrong place to post this. The last place I posted got me a fairly rude response. I guess vb.db people just don't want to think about XML as database. At any rate, here is what I posted: I have downloaded the final production version of VS 2005 pro after testing with Team version. I wonder if I've been screwed or if it's just too early on a Sunday morning. It seems to me that it was relatively trivial to...
14
2192
by: Angel Tsankov | last post by:
I need to make verifications in release builds. If a verification fails, an error message should be displayed and the program should be aborted. I need this solution to be portable. Then I thought of the assert macro - it provides the desired functionality but only if NDEBUG is not defined. So, I could write smth like this: #if defined NDEBUG #undef NDEBUG #include <cassert> #define NDEBUG
14
1731
by: Divick | last post by:
Hi, is it a nice idea to do assetion checks for method arguments ? I am currently redesigning a piece of code. Now the problem is that there are some assumptions for the method arguments that the code makes. It is not checking the validity of the arguments everywhere because that would lead to performance penalty. So I am think that at least assertions will be able check the arguments at least for debug version to verify the design. But...
8
2050
by: Jefffff | last post by:
Regarding the use of assertions: According to Juval Lowy's excellent coding standards document (PDF download available at www.idesign.net), every assumption in your code should have an assertion... and on average, every 5th line is an assertion. My question: Do any of you include that many assertions? I agree in principle that we should code defensively, but his recommendation just seems to go "overboard" and would result in a lot of...
10
3163
by: Matthew Wilson | last post by:
Lately, I've been writing functions like this: def f(a, b): assert a in assert b in The point is that I'm checking the type and the values of the parameters.
58
3141
by: jeffc226 | last post by:
This might be less of a design issue than a C++ language issue per se, but I have a problem with assertions. I mean, they work, of course. But there's something I'm uncomfortable with that's never been explained to my satisfaction. I recently read this explanation. "There is an effective litmus test to differentiate the cases in which you need to use assert and when you need to use genuine error checking: you use error checking for...
1
1743
by: =?iso-8859-1?Q?Daniel_Lidstr=F6m?= | last post by:
(I posted this to m.p.pocketpc.developer but got no answers) Hello! I have a problem when launching my application. It starts with firing an assertion. This assertion is inside mfc or atl it seems, and the message is the following: Debug Assertion Failed!
3
1672
by: Hugh Oxford | last post by:
I am told that I should use assertions in my testing. The problem is, because I test using a cut of live data, the data always changes. Has anyone come up against this or have they abandoned assertions generally? On a more general note, how does one reconcile a changing data set with testing driven development?
0
10134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9963
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11525
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11110
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11293
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.