Re: Can I change my code depending on the build type?
- From: musosdev <musoswire@xxxxxxxxxxxxxxxx>
- Date: Mon, 8 May 2006 10:54:01 -0700
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
- Follow-Ups:
- Re: Can I change my code depending on the build type?
- From: Steven Cheng[MSFT]
- Re: Can I change my code depending on the build type?
- References:
- Re: Can I change my code depending on the build type?
- From: Göran Andersson
- Re: Can I change my code depending on the build type?
- From: Göran Andersson
- Re: Can I change my code depending on the build type?
- Prev by Date: Re: Request.QueryString and "&" in Folder Name
- Next by Date: gridview rowdatabound cell index bug?
- Previous by thread: Re: Can I change my code depending on the build type?
- Next by thread: Re: Can I change my code depending on the build type?
- Index(es):
Relevant Pages
|