Re: Can I change my code depending on the build type?

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thanks.. think that's it.

Only problem is that for the Release profile, it won't let me select
"Release" configuration for one of projects in the solution - the only option
is debug.

Any idea why?!


"Göran Andersson" wrote:

The setting in web.config is only used if the web server does the
compilation. If you build the solution in Visual Studio, it's the
setting in the Configuration Manager that is used.

musosdev wrote:
Hi Goran...

I can't get this to work - I wonder if you could shed any light on it...

Basically, I've just setup a simple web, with a config and an aspx page,
which has the following in Page_Load()...

#if DEBUG
Response.Write("debug!");
#else
Response.Write("release!");
#endif

However, when I run this page (thru IIS), it *always* writes "debug!" - even
if I set compilation debug="false" in web.config.

Is there something else I need to enable?! I'm not using Web Publish or
anything like that, just a straightforward Rebuild and then point IE at the
webserver.

Any suggestions!?

"Göran Andersson" wrote:

Yes, that works.

I use it myself in an application that adds a lot of records to a
database. The release version puts data in a buffer and saves them when
the buffer is full or has lived a certain time, but the debug version
flushes the buffer for each record so that they show up in the database
immediately.

musosdev wrote:
I've got a function that needs to work slightly differently on the
development server from the production server, but of course I don't want to
be changing code just before compiling a release version!?

I'm thinking I could use some #if #else #endif type statements to change
certain things, depending on the build type. I'm thinking of something like
this in my .cs file...

#if DEBUG
private string MyFunc()
{
// debug version
}
#else
private string MyFunc()
{
// release version
}
#end if

Would this work!? If not, how could I achieve a similar effect? (.net 2)

Cheers


Dan

.



Relevant Pages

  • Re: How to set for debug/release
    ... That page explains that the *Build* configuration option which controls ... (Debug compilation, Release compilation, and so on), conversion follows ... If the project contains only Debug and Release configurations, ... all you need to do to generate assemblies with debugging information is ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Can I change my code depending on the build type?
    ... The setting in web.config is only used if the web server does the compilation. ... The release version puts data in a buffer and saves them when the buffer is full or has lived a certain time, but the debug version flushes the buffer for each record so that they show up in the database immediately. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Building a Release of my Solution
    ... There's no page directive for debug *or* compilation. ... Would I need to reset all those to get release mode? ... Service, go to Build and change the Configuration to Release, but it ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Building a Release of my Solution
    ... There's no page directive for debug *or* compilation. ... Would I need to reset all those to get release mode? ... I go into the Properties of the Solution as well as the Windows Service, go to Build and change the Configuration ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Strange C error
    ... Getting debug output back via wimp error boxes sounds a bit painful! ... is the length of the icon's buffer? ... variables in a function with gcc? ...
    (comp.sys.acorn.programmer)