473,473 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Code ok in DEBUG fails in Release

I have a c# function that runs fine in VS.Net when in debug mode; however,
when I switch to Relase mode or compile the app, the function fails with
"object refernce not set".

Here is the whole function:
private void GetETCStatus()
{
oConn.Open();
szSQL = "SELECT ParamValue FROM Params WHERE Param =
'ETCsAvailable'";
cmd.CommandType = CommandType.Text;
cmd.CommandText = szSQL;
object o = cmd.ExecuteScalar();
szTemp = o.ToString().ToUpper();
if (szTemp == "YES")
{
this.cmdETCs.Text = "&Disable ETCs";
bETCsAvailable = true;
}
else
{
this.cmdETCs.Text = "&Enable ETCs";
bETCsAvailable = false;
}
this.Refresh();
oConn.Close();
}

the line that fails is:
szTemp = o.ToString().ToUpper();

All I'm trying to do is retrieve one scalar value from the SQL database. I
don't need a dataset for this.

Can someone explain why it works in DEBUG and not in release? (Makes it very
difficult to troubleshoot.)

In lieu of that, can someone show me a better way to accomplish what I'm
trying to do here?
Thanks,
John

Nov 2 '05 #1
2 1784
Is this the only things that change ? If you don't run the debug and the
release code on the same datasource, it could be just that the line is
missing from the Params table...

--
Patrice

"John Beschler" <Jo**********@discussions.microsoft.com> a écrit dans le
message de news:F0**********************************@microsof t.com...
I have a c# function that runs fine in VS.Net when in debug mode; however,
when I switch to Relase mode or compile the app, the function fails with
"object refernce not set".

Here is the whole function:
private void GetETCStatus()
{
oConn.Open();
szSQL = "SELECT ParamValue FROM Params WHERE Param =
'ETCsAvailable'";
cmd.CommandType = CommandType.Text;
cmd.CommandText = szSQL;
object o = cmd.ExecuteScalar();
szTemp = o.ToString().ToUpper();
if (szTemp == "YES")
{
this.cmdETCs.Text = "&Disable ETCs";
bETCsAvailable = true;
}
else
{
this.cmdETCs.Text = "&Enable ETCs";
bETCsAvailable = false;
}
this.Refresh();
oConn.Close();
}

the line that fails is:
szTemp = o.ToString().ToUpper();

All I'm trying to do is retrieve one scalar value from the SQL database. I
don't need a dataset for this.

Can someone explain why it works in DEBUG and not in release? (Makes it very difficult to troubleshoot.)

In lieu of that, can someone show me a better way to accomplish what I'm
trying to do here?
Thanks,
John

Nov 2 '05 #2
Patrice,

Thanks for your response. I think you're right. I was looking at two
different data sources based upon whether it was production or testing.
However, it should have been the other way aroound because the datasource for
debug did not have the record, yet teh datasource for release did.

I think what happened is I got my command line params confused in VS.Net.
In 6.0 there was no difference between debug and release and I did not
realize there was a seperate command line configuration for debug/release in
VS.Net.
Always learning.

Thanks again.

"Patrice" wrote:
Is this the only things that change ? If you don't run the debug and the
release code on the same datasource, it could be just that the line is
missing from the Params table...

--
Patrice

"John Beschler" <Jo**********@discussions.microsoft.com> a écrit dans le
message de news:F0**********************************@microsof t.com...
I have a c# function that runs fine in VS.Net when in debug mode; however,
when I switch to Relase mode or compile the app, the function fails with
"object refernce not set".

Here is the whole function:
private void GetETCStatus()
{
oConn.Open();
szSQL = "SELECT ParamValue FROM Params WHERE Param =
'ETCsAvailable'";
cmd.CommandType = CommandType.Text;
cmd.CommandText = szSQL;
object o = cmd.ExecuteScalar();
szTemp = o.ToString().ToUpper();
if (szTemp == "YES")
{
this.cmdETCs.Text = "&Disable ETCs";
bETCsAvailable = true;
}
else
{
this.cmdETCs.Text = "&Enable ETCs";
bETCsAvailable = false;
}
this.Refresh();
oConn.Close();
}

the line that fails is:
szTemp = o.ToString().ToUpper();

All I'm trying to do is retrieve one scalar value from the SQL database. I
don't need a dataset for this.

Can someone explain why it works in DEBUG and not in release? (Makes it

very
difficult to troubleshoot.)

In lieu of that, can someone show me a better way to accomplish what I'm
trying to do here?
Thanks,
John


Nov 2 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: aaj | last post by:
Hi all I have written a small app on my machine that I have passed on to a colleague for testing. The problem is, as soon as he steps through in debug mode and reaches try { conn.Open();...
6
by: ss | last post by:
Hi I built an exe in console debug mode & Release mode . The console debug mode -exe works fine ...but the release mode EXE starts well but fails mid way . The exe is being started as a...
1
by: Carlos Lozano | last post by:
Hi, I have a multithreading application that reads and writes to com ports. The debug version works with no problems, but the release version don't. They are the same code, the difference is...
21
by: Chris Durkin | last post by:
I've got an ASP.NET website on my local box, set to compile to bin\Debug and bin\Release in debug and release modes. Both directories are populated with dlls, as the solution has been compiled in...
19
by: Alan Silver | last post by:
Hello, I have been developing ASP.NET with a text editor so far (better way to learn initially), and have now been trying Visual Web Developer. I want to create a project for an existing site...
2
by: John Beschler | last post by:
I have a c# function that runs fine in VS.Net when in debug mode; however, when I switch to Relase mode or compile the app, the function fails with "object refernce not set". Here is the whole...
10
by: musosdev | last post by:
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...
3
by: O.B. | last post by:
In .NET 2005, I have a C# GUI project that is dependent on a C# DLL project. When I compile the GUI project in Release mode, it copies the "debug" version of the DLL into the bin directory of the...
3
by: TBass | last post by:
Hello, Is there a way to get Visual Studio 2003 look to one directory for debug version dlls when set to DEBUG and then to another directory where I store the release version of a dll when set...
0
Oralloy
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,...
1
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.