473,792 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4147
Placing a AFX_MANAGE_STAT E(AfxGetStaticM oduleState( )); 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*******@disc ussions.microso ft.com> wrote in message
news:8C******** *************** ***********@mic rosoft.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_STAT E(AfxGetStaticM oduleState( )); 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*******@disc ussions.microso ft.com> wrote in message
news:8C******** *************** ***********@mic rosoft.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
523
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 Win32API GetVersionEx!
3
2218
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 namespace ManagedWrappers { public __gc MClass1
0
1239
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. Can anyone confirm this issue? I wrote a little program that demonstrates this behaviour: Main.cpp:
2
1054
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, -- Tom Tempelaere.
6
2754
by: ad | last post by:
How can we assign file extension using FileUpload?
5
7059
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 like to convert it to C# and if that is not possible to manage C++. I want to use the DLL in a larger VB.Net program. Is there a tool that will convert C++ to C#? Are there any articles/papers/examples on converting C++ to C#? Are there any...
3
1528
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
1971
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 new format (compiling with /clr:OldSyntax): everything works and compiles fine. Unfortunately, I cannot link to the newly created DLL from any other application/DLL: LNK2019: unresolved external symbol. I've checked the DLL
3
4849
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 pointers (delegates). I assume I need to use the array< T keyword to allocate an array of delegates, and then initialize the array by setting each array element to the pointers (handles) of the functions I'll be invoking. I've been trying to...
0
9670
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
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10159
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
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9033
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
7538
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
6776
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();...
1
4111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2917
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.