Home All Groups Group Topic Archive Search About

turn off assertions in VB 2005

Author
28 Oct 2006 5:51 PM
douglass_davis
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?


Author
28 Oct 2006 6:07 PM
Kerry Moorman
Douglass,

Debug methods are not included in the Release build.

Kerry Moorman


Show quoteHide quote
"douglass_da***@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
>
>
Author
28 Oct 2006 8:09 PM
douglass_davis
ok... thanks.  would be a nice feature.

--
http://www.douglassdavis.com

Kerry Moorman wrote:
Show quoteHide quote
> Douglass,
>
> Debug methods are not included in the Release build.
>
> Kerry Moorman
>
>
> "douglass_da***@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
> >
> >
Author
29 Oct 2006 6:01 PM
Jay B. Harlow
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


<douglass_da***@earthlink.net> wrote in message
Show quoteHide quote
news:1162066150.296366.312000@k70g2000cwa.googlegroups.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
>>
>>
>> "douglass_da***@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
>> >
>> >
>
Author
29 Oct 2006 8:49 AM
Theo Verweij
You can also use your own build types:

Goto the menu Build - Configuration Manager, and select <new> under
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.


douglass_da***@earthlink.net wrote:
Show quoteHide quote
> 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
>