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 10 1517
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
fantastic! cheers :D
"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
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
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
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
Hi Dan,
As for the following behavior you mentioned:
============
it won't let me select
"Release" configuration for one of projects in the solution - the only
option
is debug.
============
this is due to the new dynamic compilation model of ASP.NET 2.0
application, and as for ASP.NET 2.0 web project, it is different from
original ASP.NET 1.X/VS 2003 web project, there is no prebuilt project
assembly, all the stuffs are dynamically get compiled. So the debug/release
is depend on the web.config file's <compilation debug=xxx> setting. The
following blog article has a detailed description on the new compilation
behavior:
#Debug and Release Builds in ASP.NET 2.0 http://odetocode.com/Blogs/scott/arc...1/15/2464.aspx
Also, for ASP.NET 2.0 application, we can precompile the whole site, and
the ASP.NET dev team has provided a web deployment project that can help
control the precompilation more convenient which include specifying the
release/debug precompilation setting:
#Visual Studio 2005 Web Deployment Projects http://msdn.microsoft.com/asp.net/re...structure/wdp/
Hope this helps.
Regards,
Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Hi Steven,
That's the third time I've read that blog post :o) Unfortunately, I'm still
no wiser.
Reading that, it looks like I can't get a release build of my code from
VS2005 unless I use the Publish command - is that right?
If that's the case, that's fine - but I'm getting "Ambiguous match" problems
when I do that. Is there no way to make a Release build without Publish or
WDP?
Thanks for your time (and patience!)
Dan
"Steven Cheng[MSFT]" wrote: Hi Dan,
As for the following behavior you mentioned:
============ it won't let me select "Release" configuration for one of projects in the solution - the only option is debug. ============
this is due to the new dynamic compilation model of ASP.NET 2.0 application, and as for ASP.NET 2.0 web project, it is different from original ASP.NET 1.X/VS 2003 web project, there is no prebuilt project assembly, all the stuffs are dynamically get compiled. So the debug/release is depend on the web.config file's <compilation debug=xxx> setting. The following blog article has a detailed description on the new compilation behavior:
#Debug and Release Builds in ASP.NET 2.0 http://odetocode.com/Blogs/scott/arc...1/15/2464.aspx
Also, for ASP.NET 2.0 application, we can precompile the whole site, and the ASP.NET dev team has provided a web deployment project that can help control the precompilation more convenient which include specifying the release/debug precompilation setting:
#Visual Studio 2005 Web Deployment Projects http://msdn.microsoft.com/asp.net/re...structure/wdp/
Hope this helps.
Regards,
Steven Cheng Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights. Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Thanks for your response Dan,
Actually the fixed "Debug" option in the VS 2005 SOLUTION for ASP.NET
project is just a dummy setting which won't make actual effect. That just
tell us that for ASP.NET 2.0 project, there is no concept of development
time prebuilt project assemblies. And for ASP.NET 2.0 pages and classes in
the App_Code, they will be dynamically compiled, and the debug/release
version just rely on the web.config's <compilation debug=...> setting.
Are you correctly put such case dependent code in page's codebehind for in
custom helper class's file? If in custom helper class, maybe you can
consider arrange them into a separate class library which will be more
convenient to control the debug/release output since class library project
is prebuilt at development time.
Regards,
Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Steven,
Thanks for the patience!
Okay, so last first... yeah, I could do that. But the code I'm altering is
really integral to the application, so I don't *really* want to seperate it
out if I can help it.
What's more worrying though, is that whether I compilation debug= to true OR
false in my web.config, I always get the debug version, which would indicate
that it doesn't seem to be making any difference?
I don't actually need the alternate functions, I could just replace before
the final build, but it's the fact that I can't seem to switch it which is
making me persevere!
Any ideas?!
"Steven Cheng[MSFT]" wrote: Thanks for your response Dan,
Actually the fixed "Debug" option in the VS 2005 SOLUTION for ASP.NET project is just a dummy setting which won't make actual effect. That just tell us that for ASP.NET 2.0 project, there is no concept of development time prebuilt project assemblies. And for ASP.NET 2.0 pages and classes in the App_Code, they will be dynamically compiled, and the debug/release version just rely on the web.config's <compilation debug=...> setting.
Are you correctly put such case dependent code in page's codebehind for in custom helper class's file? If in custom helper class, maybe you can consider arrange them into a separate class library which will be more convenient to control the debug/release output since class library project is prebuilt at development time.
Regards,
Steven Cheng Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights. Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dan Hartshorn |
last post by:
VS.NET 2003, C#, Windows Server 2003. I have a datagrid and I want the
last column to be either an EditCommandColumn or a template column,
depending on a value I have. The value changes for each row. So some
rows will have an EditCommandColumn, others just a text message in the
last column. Is this possible? I am already using the ItemDataBound
method to perform some function on each row, but I can't seem to
change the datagrid's column...
|
by: Tom |
last post by:
How can I make code not execute for a debug build, but do
execute for a production build?
I have code which prompts for an account and password when
the program starts up. It is a pain to have to answer that
when I repeatly run the program during debugging, but it
is desired by my client. Presently I just comment it out
when I am debugging, but I was wondering if there was a
more automatic way? Some type of conditional compilation...
|
by: Jeff User |
last post by:
I have my datagrid running pretty much with a EditCommandColumn and
some TemplateColumn columns.
There are two types of appearance changes I would like to make
programatically from my C# code depending on various conditions.
Column items are typical Labels in <ItemTemplate> and TextBoxes in
<EditItemTemplate> forms.
When the user clicks Edit, I would like to do the following:
|
by: Wayne Cressman |
last post by:
I'm writing a function to dynamically change a form validation script
depending upon the user's choices.
The form onsubmit is:
onsubmit="writevalidate(this.select.value);return document.MM_returnValue"
I then have the following function
function writevalidate(selectvalue) {
var1 = "\'form1\',\'type\',\'#q\',\'0\',\'Please enter your
|
by: Zytan |
last post by:
This returns the following error:
"Cannot modify the return value of
'System.Collections.Generic.List<MyStruct>.this' because it is
not a variable"
and I have no idea why! Do lists return copies of their elements?
Why can't I change the element itself?
class Program
{
private struct MyStruct
| |
by: pozitronic |
last post by:
Hey all,
I would like to do the following:
I have 3 radio boxes.
<input name="br" type="radio" value="first">Button1<br>
<input name="br" type="radio" value="second">Button2<br>
<input name="br" type="radio" value="third" />Button3<br>
|
by: Gilbert Tordeur |
last post by:
Hello,
It is about a VB2008 intranet application. It uses a SQL Server database.
The ConnectionString is defined in the
connectionStrings section of the web.config file. This application uses
ObjectDataSource objects, defined in design mode.
I would like to use a different database depending on the execution
environment (development or production).
|
by: mistral |
last post by:
Does it possible change favicon icon depending on browser type:
display favicon.ico for Internet Explorer browsers, and favicon.gif
for the rest browsers? Problem is that ugly MSIE can display only .ICO
favicons, whereas other browsers support any favicon type - gif, png,
jpg. Since gif favicons has much better quality than ico file, I'm
wondering does it possible sort browsers with javascript and show
appropriate favicon type for...
|
by: Peng Yu |
last post by:
Hi,
It is possible to change the length of "\t" to a number other than 8.
std::cout << "\t";
Thanks,
Peng
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |