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. 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: Can I change my code depending on the build type?
    ... "Release" configuration for one of projects in the solution - the only option ... is debug. ... if I set compilation debug="false" in web.config. ... the buffer is full or has lived a certain time, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Gesucht - Virensoftware die funktioniert
    ... Server specifications ... - winmsd output from the OSCE server ... To turn on the server debug program: ... Setting window appears 3. select the Enable debug log check box. ...
    (microsoft.public.de.german.exchange2000.general)
  • Re: ssh as non-root user
    ... The server is reporting the following to the client: ... server offers auth methods ''. ... debug: ... Unauthorized access or use of this computer system may subject violators to ...
    (SSH)
  • Re: hostbased auth between commercial and OpenSSH
    ... The server just rejects hostbased from OpenSSH client saying method is ... Client side debug snippet (I've got hostbased as only ... client user 'myusername', server user 'myusername', ...
    (comp.security.ssh)
  • SSH Debugging <-- compatibility
    ... Connecting to server, port 22... ... debug: Ssh2/ssh2.c:1956/main: Entering event loop. ... SSH_CROSS_ALGORITHMS packet from connection protocol. ... This is an evaluation version of the SSH Secure Shell Windows Server. ...
    (comp.security.ssh)