且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我可以根据构建类型更改我的代码吗?

更新时间:2023-12-05 13:59:58

是的,这是有效的。


我自己在一个为

数据库添加大量记录的应用程序中使用它。发布版本将数据放入缓冲区并在缓冲区已满或已经存在一定时间时保存它们,但调试版本

为每条记录刷新缓冲区他们立即出现在数据库中




musosdev写道:
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:
我有一个需要的功能从生产服务器开始,在
开发服务器上的工作方式略有不同,但当然我不想在编译发布版本之前更改代码!?

我我想我可以使用一些#if #else #endif类型的语句来改变某些东西,具体取决于构建类型。我正在考虑在我的.cs文件中使用
这个...
#if DEBUG
私人字符串MyFunc()
{
//调试版
}
#else
私人字符串MyFunc()
{
//发布版
}
#end if

这会起作用吗??如果没有,我怎么能达到类似的效果? (.net 2)

干杯

Dan
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



太棒了!欢呼:D


" G ?? ran Andersson"写道:
fantastic! cheers :D

"G??ran Andersson" wrote:
是的,这是有效的。

我自己在一个为
数据库添加大量记录的应用程序中使用它。发布版本将数据放入缓冲区并在缓冲区已满或已经存在一定时间时保存它们,但调试版本刷新每个记录的缓冲区以便它们显示在数据库中
musosdev写道:
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:
我有一个功能需要在生产服务器的
开发服务器上略有不同,但是当然我不想在编译发布版本之前更改代码!?我想我可以使用#if #else #endif类型的语句改变某些事情,具体取决于构建类型。我正在考虑在我的.cs文件中使用
这个...
#if DEBUG
私人字符串MyFunc()
{
//调试版
}
#else
私人字符串MyFunc()
{
//发布版
}
#end if

这会起作用吗??如果没有,我怎么能达到类似的效果? (.net 2)

干杯

Dan
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



嗨Goran .. 。


我无法解决这个问题 - 我想知道你是否可以解决这个问题...


基本上,我刚刚设置了一个简单的网页,有一个配置和一个aspx页面,

在Page_Load()中有以下内容......


#如果DEBUG

Response.Write(" debug!");

#else

Response.Write(" release!" );

#endif


但是,当我运行这个页面(通过IIS)时,*总是*写入debug! - 如果我设置编译debug =" false"甚至

在web.config中。


我需要启用其他东西吗?!我没有使用Web Publish或

这样的东西,只是一个简单的Rebuild,然后在

网络服务器上点IE。


任何建议!?


" G ?? ran Andersson"写道:
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:
是的,这是有效的。

我自己在一个为
数据库添加大量记录的应用程序中使用它。发布版本将数据放入缓冲区并在缓冲区已满或已经存在一定时间时保存它们,但调试版本刷新每个记录的缓冲区以便它们显示在数据库中
musosdev写道:
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:
我有一个功能需要在生产服务器的
开发服务器上略有不同,但是当然我不想在编译发布版本之前更改代码!?我想我可以使用#if #else #endif类型的语句改变某些事情,具体取决于构建类型。我正在考虑在我的.cs文件中使用
这个...
#if DEBUG
私人字符串MyFunc()
{
//调试版
}
#else
私人字符串MyFunc()
{
//发布版
}
#end if

这会起作用吗??如果没有,我怎么能达到类似的效果? (.net 2)

干杯

Dan
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