Cannot ever open fstream object in DLL?
-
Howdy all, First off this board is great, thanks for everyone who helped me earlier. I'm explicitly loading a DLL and constructing an object of type CTestDLL. In this class's constructor is the following code: CTestDLL::CTestDLL() { fstream outfile; cerr << "constructed"; outfile.open("c:\test.log", ios::app); if (!outfile) { cerr << "could not open file"; exit(1); } } It always fails to open, but the constructor's definitely being called. In addition to failing to open, I always get "the instruction at 0x00000000 referenced memory at 0x00000000. The memory could not be read". I've tried creating the file manually, then trying to open it, with no luck. I've tried casting the const char* to a (LPCTSTR), using a CString, making the whole class visible, or just the individual methods (constructor/destructor) visible, all with the same results and same error. Any ideas? I've googled and found others with the same problem, but unfortunately no answers. If I take the fstream code out the object contructs fine, but the fstream seems to muck things up.
-
Howdy all, First off this board is great, thanks for everyone who helped me earlier. I'm explicitly loading a DLL and constructing an object of type CTestDLL. In this class's constructor is the following code: CTestDLL::CTestDLL() { fstream outfile; cerr << "constructed"; outfile.open("c:\test.log", ios::app); if (!outfile) { cerr << "could not open file"; exit(1); } } It always fails to open, but the constructor's definitely being called. In addition to failing to open, I always get "the instruction at 0x00000000 referenced memory at 0x00000000. The memory could not be read". I've tried creating the file manually, then trying to open it, with no luck. I've tried casting the const char* to a (LPCTSTR), using a CString, making the whole class visible, or just the individual methods (constructor/destructor) visible, all with the same results and same error. Any ideas? I've googled and found others with the same problem, but unfortunately no answers. If I take the fstream code out the object contructs fine, but the fstream seems to muck things up.
-
Thank you so much, what a silly mistake! What's weird is it fails even if I say "test.log" -- for some reason I have to state the drive.