By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,524 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,524 IT Pros & Developers. It's quick & easy.

turn off assertions in VB 2005

P: n/a

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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.netwrote in message
news:11**********************@k70g2000cwa.googlegr oups.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 discussion thread is closed

Replies have been disabled for this discussion.