473,326 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to wrap MFC extension DLL using managed C++

I need to wrap a MFC extension Dll with export class(let's suppose it's
named CA)
so we could use it in C#.
The dll is provided by third party vendor which means I couldn't modify it.
A managed c++ library project was created to wrap this dll with a __gc
class(let's suppose it's named CGA).
class CGA contain an instance of class CA and explicitly delegates
implementation to the CA's methods
The problem is any call to methods of class CA(from the wrap class CGA of
course) would
cause AssertFailure and it's turn out that the function AfxGetInstance
failed with null-pointer returned.
Is there any solution to this problem?

BTW: English is not my mothertongue, so feel free to correct me if I'm wrong.
Nov 17 '05 #1
2 4132
Placing a AFX_MANAGE_STATE(AfxGetStaticModuleState( )); call at the start of
each MFC DLL functions can solve many such problems, but since you don't
have the code to the dll, this method will not work. Try working this out
with the vendor.

-Atul, Sky Software http://www.ssware.com
Shell MegaPack For ActiveX & .Net - Windows Explorer Like Shell UI Controls

"YeJianWei" <Ye*******@discussions.microsoft.com> wrote in message
news:8C**********************************@microsof t.com...
I need to wrap a MFC extension Dll with export class(let's suppose it's
named CA)
so we could use it in C#.
The dll is provided by third party vendor which means I couldn't modify
it.
A managed c++ library project was created to wrap this dll with a __gc
class(let's suppose it's named CGA).
class CGA contain an instance of class CA and explicitly delegates
implementation to the CA's methods
The problem is any call to methods of class CA(from the wrap class CGA of
course) would
cause AssertFailure and it's turn out that the function AfxGetInstance
failed with null-pointer returned.
Is there any solution to this problem?

BTW: English is not my mothertongue, so feel free to correct me if I'm
wrong.

Nov 17 '05 #2
Thank Atul, but I afraid that it would be very difficult for me to get the
help from the vendor
Is there any other solution to this problem?

"Atul" wrote:
Placing a AFX_MANAGE_STATE(AfxGetStaticModuleState( )); call at the start of
each MFC DLL functions can solve many such problems, but since you don't
have the code to the dll, this method will not work. Try working this out
with the vendor.

-Atul, Sky Software http://www.ssware.com
Shell MegaPack For ActiveX & .Net - Windows Explorer Like Shell UI Controls

"YeJianWei" <Ye*******@discussions.microsoft.com> wrote in message
news:8C**********************************@microsof t.com...
I need to wrap a MFC extension Dll with export class(let's suppose it's
named CA)
so we could use it in C#.
The dll is provided by third party vendor which means I couldn't modify
it.
A managed c++ library project was created to wrap this dll with a __gc
class(let's suppose it's named CGA).
class CGA contain an instance of class CA and explicitly delegates
implementation to the CA's methods
The problem is any call to methods of class CA(from the wrap class CGA of
course) would
cause AssertFailure and it's turn out that the function AfxGetInstance
failed with null-pointer returned.
Is there any solution to this problem?

BTW: English is not my mothertongue, so feel free to correct me if I'm
wrong.


Nov 17 '05 #3

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

Similar topics

3
by: Ian Rowland | last post by:
Is there a way, using managed code, to determine the Service Pack of the OS without resorting to registry calls? OSVersion doesn't give this information. It seems the only way is to use the...
3
by: mirek | last post by:
Hi, I've got problem building managed class library to wrap unmanaged code. I created managed class library using standard patten: #include "../Unmanaged/Class1.h" //Class1 unmanaged ...
0
by: Dirk Evertz | last post by:
Hi all, I've experienced a problem when passing a smart-pointer (_com_ptr_t) by value to another function using managed extensions. This only seems to happen if the object is created via new....
2
by: TT (Tom Tempelaere) | last post by:
Hey everyone, Why is there no foreach extension in managad C++? Will it be in a future release of managed C++? For instance, the keyword __foreach could be reserved to do that. Thanks, --...
6
by: ad | last post by:
How can we assign file extension using FileUpload?
5
by: Michael D. Reed | last post by:
I have legacy DLL code written in C++ that is essentially C code, an implementation of a set of formulas used in our industry. There are no DB or GUI interfaces, just exposed methods. I would...
3
by: Allen Maki | last post by:
I am using multiple arrays to make tables of rows and columns. When using C++ I was able to manipulate texts by using cout << setw(3) << .... using directives iomanip.h and iostream.h.
3
by: Andreas | last post by:
Hi! I'm currently developing a DLL that makes use of C++ and .net (mixed) using Visual Studio 2003. Now, as I wanted to move to the new Visual Studio 2005, I converted this project into the...
3
by: David K in San Jose | last post by:
I'm using managed (CLR) C++ in VS2005 to create a Windows app that contains a form named "MyForm". In the code for that form I'm trying to invoke some static functions by using an array of function...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.