Hi,
We have a large code base of "regular" C++ code (not MFC, COM or ATL).
With VC6.0, we used to compile the "regular" C++ code as static
libraries (.lib files), and then we would link the .lib files with an
MFC GUI "front end".
The "regular" C++ can also run as a standalone .EXE (with no GUI).
The "regular" C++ can be built and runs correctly as a standalone .EXE
with VC7.1 too.
We are now contemplating upgrading the GUI "front end" to C#. This
entails adding a Managed C++ "wrapper" DLL, which gets called frmo C#,
and in turn calls the Unmanaged C++.
The unmanaged C++ uses static variables, and so we have followed the
instructions in the MSDN article on "Converting Managed Extensions for
C++ Projects from Pure Intermediate Language to Mixed Mode". The
initialisation of static variables seems to be working correctly
(verified with breakpoints).
We have got to the point where the C# calls the Managed C++ Wrapper,
which calls Unmanaged C++, but we are getting a
System.NullReferenceException.
The exception is happening when a call is made to fputs, to output a
string to the sdterr, when function _lock_file calls
EnterCriticalSection.
Here is the stack trace:
NTDLL.DLL!_RtlEnterCriticalSection@4() + 0x11e87
msvcr71.dll!_lock_file(void * pf=0x1009d0d4) Line 236 C
msvcr71.dll!fputs(const char * string=0x1009df74, _iobuf *
stream=0x1009d0d4) Line 53 + 0x9 C
AppsEMSWrapper_Take1.dll!RTDiagStream::write(const char *
string=0x1009df74) Line 120 + 0x12 C++
AppsEMSWrapper_Take1.dll!showBanner() Line 189 + 0x13 C++
AppsEMSWrapper_Take1.dll!RTMain::mainLine() Line 221 C++
AppsEMSWrapper_Take1.dll!RTMain::entryPoint(int argc=0x00000006, const
char * const * argv=0x0012f624) Line 67 C++
AppsEMSWrapper_Take1.dll!ModelInterface::modelMain EntryPoint(int
RunAsLCT=0x00000001) Line 130 + 0xb C++
appsemswrapper_take1.dll!AppsEMSWrapper_Take1.Mode lInterfaceWrapper.modelMainEntryPointWrapper(__int 32
RunAsLCT = 0x1) Line 17 C++
ConsoleApplication1.exe!ConsoleApplication1.Class1 .Main(string[] args
= {Length=0x0}) Line 33 C#
Any ideas, anyone ?????
Thanks !!! 1 1745
Probably you did not initialized C runtime
Did you call
__crt_dll_initialize()
George.
"Yoni Rabinovitch" <yo**************@adc.com> wrote in message
news:d9**************************@posting.google.c om... Hi,
We have a large code base of "regular" C++ code (not MFC, COM or ATL).
With VC6.0, we used to compile the "regular" C++ code as static libraries (.lib files), and then we would link the .lib files with an MFC GUI "front end".
The "regular" C++ can also run as a standalone .EXE (with no GUI).
The "regular" C++ can be built and runs correctly as a standalone .EXE with VC7.1 too.
We are now contemplating upgrading the GUI "front end" to C#. This entails adding a Managed C++ "wrapper" DLL, which gets called frmo C#, and in turn calls the Unmanaged C++.
The unmanaged C++ uses static variables, and so we have followed the instructions in the MSDN article on "Converting Managed Extensions for C++ Projects from Pure Intermediate Language to Mixed Mode". The initialisation of static variables seems to be working correctly (verified with breakpoints).
We have got to the point where the C# calls the Managed C++ Wrapper, which calls Unmanaged C++, but we are getting a System.NullReferenceException.
The exception is happening when a call is made to fputs, to output a string to the sdterr, when function _lock_file calls EnterCriticalSection.
Here is the stack trace:
NTDLL.DLL!_RtlEnterCriticalSection@4() + 0x11e87 msvcr71.dll!_lock_file(void * pf=0x1009d0d4) Line 236 C msvcr71.dll!fputs(const char * string=0x1009df74, _iobuf * stream=0x1009d0d4) Line 53 + 0x9 C AppsEMSWrapper_Take1.dll!RTDiagStream::write(const char * string=0x1009df74) Line 120 + 0x12 C++ AppsEMSWrapper_Take1.dll!showBanner() Line 189 + 0x13 C++ AppsEMSWrapper_Take1.dll!RTMain::mainLine() Line 221 C++ AppsEMSWrapper_Take1.dll!RTMain::entryPoint(int argc=0x00000006, const char * const * argv=0x0012f624) Line 67 C++ AppsEMSWrapper_Take1.dll!ModelInterface::modelMain EntryPoint(int RunAsLCT=0x00000001) Line 130 + 0xb C++
appsemswrapper_take1.dll!AppsEMSWrapper_Take1.Mode lInterfaceWrapper.modelMai
nEntryPointWrapper(__int32 RunAsLCT = 0x1) Line 17 C++ ConsoleApplication1.exe!ConsoleApplication1.Class1 .Main(string[] args = {Length=0x0}) Line 33 C#
Any ideas, anyone ?????
Thanks !!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Yoni Rabinovitch |
last post by:
Hi,
We have a large code base of "regular" C++ code (not MFC, COM or ATL).
With VC6.0, we used to compile the "regular" C++ code as static
libraries (.lib files), and then we would link the...
|
by: Adam McKee |
last post by:
We are using Visual Studio.NET 2003 in our project with .NET framework
1.1. One of our libraries is a mixed-mode dll assembly consisting of
one managed C++ library, and several unmanaged C++...
|
by: Thomas W. Brown |
last post by:
I have setup Console redirection within my Console app (via Console.SetOut
and Console.SetErrror) to route console WriteLine calls to a logfile. This
works just fine with one exception...
I use...
|
by: Kurt Smith |
last post by:
We are in the process of creating a managed C++ library to wrap some
existing unmanaged code. The unmanaged code makes use of the STL. We
are seeing NULL pointer exceptions whenever we construct...
|
by: |
last post by:
I am stuck in a situation and I do believe that this should work, but it
doesn't.
I have a unmanaged dll, that uses MFC. This works great.
Now I recompile the unmanaged dll so it contains...
|
by: George Economos |
last post by:
Is the following code correct (managed c++ console app):
// native classes
#pragma unmanaged
class MyException {};
class MyThrow
{
MyThrow()
{
|
by: Lee Crabtree |
last post by:
I'm starting work on what will eventually be a very, very LARGE project. A
lot of the project involves taking C/C++ class libraries and wrapping them
with managed C++. I'd like to minimize the...
|
by: Herby |
last post by:
Is possible to have a managed method within a Native(un-managed) class
within a \clr project?
E.g.
class myClass
{
public:
#pragma managed
void myMethod(void);
|
by: Søren Dreijer |
last post by:
Hi,
I have a mixed C#, managed C++ and unmanaged C++ project.
The managed class calls a method which exists in an unmanaged singleton
class. During the entire lifetime of the application, this...
|
by: caa |
last post by:
I have made a simple text example. I have two projects. First is an
unmanaged static lib, containing function F(), which created an object
of type A and throws an exception. The second project is...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |