Click to See Complete Forum and Search --> : run in debug, doesn't work in release mode
darknight
April 22nd, 2005, 08:43 AM
hi all.
i have .net C# project which uses a C++ project as a class library.
from c++ code a connection to the ODBC database is made. when i run
the program in debug mode, it works properly, however, in release mode
(i mean with CTRL+ F5) it gives the database connection error below:
[Microsoft][ODBC Driver for Oracle][Oracle]ORA-01017:invalid username/password; logon denied
can anyone help me?
is this a registery problem, or do i need a library,or etc?
andreshs1
April 22nd, 2005, 04:47 PM
Hi,
most of the times the error is that the variables are not initialized correctly.
Make sure all the variables are initialized;
or post some code
Good Luck
Andreas Masur
April 23rd, 2005, 02:00 PM
Surviving the Release version (http://www.codeproject.com/debug/survivereleasever.asp)
darknight
April 25th, 2005, 05:00 AM
hi again,
thanks for the replies. Now, i can connect to the DB, but still i have a problem.
in the code i want to write the data into a file. the code is as below:
char s[255];
FILE *fp;
sprintf(s,"%s\\output.txt",PROJECT_DIR);
fp=fopen(s,"w");
fprintf(fp,"Transmitter Intermodulation: SCENARIO-1\n");
again, the project works fine in debug mode, however, in release mode it gives the error below:
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at fprintf(_iobuf* , SByte* )
i cannot see the problem, i will be appreciate to any help.
thanks.
cilu
April 25th, 2005, 08:17 AM
Are you still using FILE in .NET?! :confused: Didn't you hear of FileInfo, FileStream, StreamWritter/Reader?
Anyway, I suspect that your file path is not set appropriatelly, so the open fails. You should test the return value.
char s[255];
FILE *fp = NULL;
sprintf(s,"%s\\output.txt",PROJECT_DIR);
fp = fopen(s,"w");
if(fp == NULL)
{
cout << "error opening file";
return;
}
fprintf(fp,"Transmitter Intermodulation: SCENARIO-1\n");
fclose(fp);
darknight
April 25th, 2005, 09:57 AM
at last, i solved the problem. I don't know why, but in release mode the program cannot get the file directory from the specified class by using sprintf() method. Then i used System::String and then i could have read the directory correctly.
i was working in c++ code, and if i begin to use StreamReader, StreamWriter, etc, i have to rewrite the code from the start.
anyway,
thanks for the help.
cilu
April 25th, 2005, 11:38 AM
So you cannot use System::IO::StreamReader, but you can use System::String. Cool! :D
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.