This lib file is used by a managed dll.
Unfortunately when I run the code it crashes when I create the fstream
object.
I have a hunch that it is a simple problem of configuring my project
file. But the only file I have linked is msvcrtd.lib.
Any help would be greatly appreciated.
Thanks,
Ramsey
These are the options I set in the project settings for the lib file:
-------------------------------------------------------------------------
Librarian->General->Additional Dependencies-> msvcrtd.lib
These are the options I set in the project settings for managed dll:
-------------------------------------------------------------------------
Linker->Input->Additional Dependencies-> mscoree.lib msvcrtd.lib
...\Debug\LibFi le.lib
This is the code in the cpp file of the lib project:
------------------------------------------------------
#include <fstream>
using namespace std;
char * Class1::GetMess age()
{
fstream temp("temp.out" ,ios::out); // crashes right here in the ios
file line 140
return "LibFile::GetMe ssage()";
}
This is the error I get:
-------------------------
"An unhandled exception of type 'System.NullRef erenceException '
occurred in proj1.dll
Additional information: Object reference not set to an instance of an
object."
top lines of stack trace (I took out the ends to make it more
readable):
-------------------------------------------------------------------------
NTDLL.DLL!77f88 216()
mscorwks.dll!79 1b308a()
msvcr71d.dll!_h eap_alloc_dbg ...
msvcr71d.dll!_u nlock(int locknum=) Line 347 C
proj1.dll!std:: basic_ios<char, std::char_trait s<char> >::init ...
proj1.dll!std:: basic_ostream<c har,std::char_t raits<char>
::basic_ostrea m.... proj1.dll!std:: basic_iostream< char,std::char_ traits<char>::basic_iostre am.... proj1.dll!std:: basic_fstream<c har,std::char_t raits<char>::basic_fstrea m....
proj1.dll!LibFi le::Class1::Get Message() Line 18 C++