473,666 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

fstream use in unmanaged lib file linked to managed dll

I have a unmanaged lib file that creates an fstream object.
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++

Nov 17 '05 #1
0 1016

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

Similar topics

4
7173
by: repstat | last post by:
Hi I have a project which is going to be doing some string manipulation which needs to be pretty fast. The user interface is going to be written in C#. I am going to write the string handling functions in a C++ DLL. My first question is, if I insert a C++ project into my C# solution, how will VS.NET know that I want it to be unmanaged code? I intend to be calling the DLLs functions using DllImport. I've heard that you can have unmanaged...
5
1730
by: Andrew | last post by:
I want to use a managed c++ class from an unmanaged class. Here is my code: // *** Unmanaged Code // .h file class UnmanagedClass { public: // Other stuff here
1
1645
by: Sparhawk | last post by:
Hi, my company is going to migrate a large VC++ application to .NET to make use of Windows Forms (the old class library is not updated any more). We are not planning to migrate the rest of the code which works well. I understand the basic concept: our code is unmanaged, Windows Forms is Managed and Unmanaged may not call Managed code. I read about Wrappers, PInvoke, Runtime Callable Wrappers for COM and about It just
1
2256
by: RaKKeR | last post by:
Hi, I'm trying to wrap my unmanaged c++ code into a managed c++ wrapper. The problem is VC .NET doesn't seem to find the namespaces defined in my unmanaged code. Let's say I have a file "server.h" with a namespace server. When I include this file in another file that will be compiled as managed, the compiler gives me the following error: C2871: 'server' : a namespace with this name does not exist
0
980
by: Ditlef | last post by:
We have a large C++ COM-based project we will migrate (slowly) to .NET. We have several basic libraries we need to wrap with C++ managed wrapper libraries. Having C++ runtime Debug/Release mixed with managed code seems to make problems for project setup. The document: Team Development with Visual Studio .NET and Visual SourceSafe http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/tdlg_ch5.asp contains...
6
1305
by: marek | last post by:
Hello All, we are doing a quite a big project that contains at the lowest level an unmenaged c++ classes. Above it there are managed wrappers and at the top there are ASP.NET pages. Can anyone tell me how to force ASP.NET not to "clear" or reinitialize unmenaged global or static variables that are set on unmanaged level between successive requests?
2
1330
by: Mythran | last post by:
I have a freeware UnManaged - Non-Com DLL I want to use. Basically, in a perfect world, I would like to embed this library into a VB.Net class library (managed), strong name it and store it into the gac. Now, the installer would just need to install this VB.Net library into the GAC w/o the unmanaged dll (because it would be embedded into the managed dll thus wouldn't need to install the 3rd party as a separate file. Is this possible? ...
3
1386
by: shu | last post by:
I get a _CrtIsValidHeapPointer assertion when trying to have a unmanaged static object linked to my managed project. I have tried to reduce the problem to a very simple case: One unmanaged .cpp file (compiled with "No Common language Runtime Support") added to a managed .exe project. This unmanaged .cpp declares a static object, with its constructor and destructor.
9
3117
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for this, I want to use it. Is it possible to call Managed class functions from Unmanaged class? How to do it? I did something like this. I declared a managed class (in C++ CLI) called as MyManagedClass whose
0
8444
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8869
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8551
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7386
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.