 |
|
 |
The trick is the bit that you have to do all your own marshaling.
With IJW, you have to the marshaling *everytime* you use the function. With P/Invoke, most of this is either automatic, or simple and done just once - an once you get a few basic rules down, writing P/Invoke definitions are almost trivial.
Where I see IJW as being a lifesaver is when you have to import a C++ class from a DLL. The alternative is dealing with munged names.
|
|
|
|
 |
|
 |
Hi everybody,
I'm trying to use a complicated MFC-control in a .Net application (using WS2003) and every now and then the application crashes in the MFC part. I have extended the DLL in which is the MFC-control with several simple MC++ wrapper classes and they seem work nicely. I can display the control, but when I start to manipulate the control and it has to redraw a few times, the control crashes in the MFC part while allocating new memory. Somehow I have the feeling that M$ did finish this in the VS2003. Does it work better with VS2005?
Cheers
gunag
|
|
|
|
 |
|
 |
Hi,
I'm trying to convert an MFC-DLL with a GUI control, which works with VC6, to .NET (VS2003) using a mixed mode DLL. So far I can compile the project, but when I run it, the DLL crashes when it tries to resolve resources in the MFC-DLLs by using AfxFindResourceHandle. Does anybody have an idea how to solve this?
Besides I would be really happy if one of those mc++ gurus could publish a sample of mixed mode c++ dll project because so far everybody just writes in the internet one should write a wrapper around some old dll, but there are no examples availible. To me it seems like Microsoft does not want the developers to use old MFC-Code in the new products. Otherwise they would have shown a way how to access c++ dlls in a proper way - P/Invoke is just no really nice way for C++ - DLLs.
Cheers
Gunag
|
|
|
|
 |
|
 |
I create a new .Net project with /clr;
Add codes like these:
char * p = new char[10];
delete [] p;
build to see such errors
error LNK2001: "void __cdecl operator delete(void *)" (??3@$$FYAXPAX@Z)
error LNK2001: "void * __cdecl operator new(unsigned int)" (??2@$$FYAPAXI@Z)
So i can not use standard C++ codes in /clr project, can i?
|
|
|
|
 |
|
|
 |
|
 |
...I have come across. I had to say it. Nish, I owe you something now.
(hope you don't mind me referring to this article on many many many interop issues on other forums. ).
|
|
|
|
 |
|
 |
.S.Rod. wrote:
That's the smartest interop article...
.S.Rod. wrote:
...I have come across
Uhm, are you serious? Or just havin a go at me?
if(S_Rod.IsSincere())
{
Output.Thanks("Hey, thanks bud. IJW rocks!");
}
else
{
Output.Uhm("Er, sorry, but I do not see what else to include in an IJW intro!");
_exit_conversation(-1);
}
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
 |
|
 |
Believe it or not, I am being serious. I declined to even give a glance at MC++ since last year, and now that, after a semester of struggles and frustration with [DllImport] marshaling issues, I know that there can be no match for a direct native call. And the idea of boasting someday with a P/Invoke debugger is just vanishing. Indeed! Youpla!
|
|
|
|
 |
|
|
 |
|
 |
Nish is too modest to mention this - I'll get him over that modesty one day - but he and I are also writing a book for Addison Wesley that is dedicated to mixing Visual C++/MFC and .NET.
The book illustrates how to enhance your current MFC applications by interfacing to a select group of .NET classes and types using managed extensions.
We're about 80% done. If you're interested, let us know and we'll notify you when it's available.
Cheers,
Tom Archer, Inside C#
Mainstream is just a word for the way things always have been -- just a middle-of-the-road, tow-the-line thing; a front for the Man serving up the same warmed-over slop he did yesterday and expecting you to say, "Thank you sir, may I have another?"
|
|
|
|
 |
|
 |
Tom Archer wrote:
I'll get him over that modesty one day
I am workin on it Tom, I am workin on it
Tom Archer wrote:
We're about 80% done. If you're interested, let us know and we'll notify you when it's available.
Yup
Nish
"I'm a bit bored at the moment so I'm thinking about writing a new programming language" - Colin Davies
My book :- Summer Love and Some more Cricket [New Win]
Review by Shog9 Click here for review[NW]
|
|
|
|
 |
|
 |
I tried to use IJW, but it dooesn´t works.
I did:
1. Creade the .dll and the .lib files
2. Create a managed c++ Project
3. I set the "Additional include Directories" to the Headers of my DLL.
4. I set my "Additional Library Directories" to the .lib file.
When I try to use Classes from my dll
e.g.
DLLClass* c = new DLLClass();
the error: error C2065: 'DLLClass' : undeclared identifier
occurs.
P.S. Maybe I linked the library in a wrong way?
Please help...
|
|
|
|
 |
|
|
 |
|
 |
Having the file with IJW call to MessageBox API I tried to call MessageBox::Show in the same file. The result is the names clash which I cannot resolve:
System::Windows::Forms::MessageBox::Show(this, str, sTitle);
error C2039: 'MessageBoxA' : is not a member of 'System::Windows::Forms'
or:
MessageBox::Show(this, str, sTitle);
error C2653: 'MessageBoxA' : is not a class or namespace name
In the start of cpp file I have:
#include "stdafx.h"
#using "mscorlib.dll"
#include "tchar.h"
#include "windows.h"
#using "System.dll"
#using "System.Drawing.dll"
#using "System.Windows.Forms.dll"
using namespace System;
using namespace System::Runtime::InteropServices;
using namespace System::ComponentModel;
using namespace System::Drawing;
using namespace System::Windows::Forms;
#include "MainForm.h"
Nish, maybe you know a way to solve the problem.
|
|
|
|
 |
|
|
 |
|
 |
Thanks. I hope there is some generic solution. After
#undef MessageBox
I can still call MessageBoxW or MessageBoxA API. This creates problems writing the code which is compiled both in ANSI and UNICODE. Maybe it's time to work only in UNICODE?
|
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Hey, guys...
Have you both ever wrote anything commercially usefull... or just fooling around???...
So, if want to be realy usefull to society why can't one of you write:
AxImp.exe /source that produces Managed C++ AxHost...
I mean, do whatever you want => Do it from TypeLib or first run AxImp.exe /source create C# and then parse it and create C++ code...
I mean not part, but full including delegates, supporting all possible types and etc...
I've picked you Nish => because you are pretty active here, and looks like you have alot of free time => lets see what you really can do...
As to you Nick: It should be obviously your task as a superviser in .NET developments at MSFT.. If you can't do it on your own => you sure can ask somebody who can there, aren't you????...
Nick and when you finished I would like to ask you:
Could you also ask somebody there to fix BUGS and not working published interfaces of .NET Control implementation... Like, IPersistStreamInit, IQuickActivate and etc...
Thnx
|
|
|
|
 |
|
 |
"Performant" is actually a French word (you Canadians ...David C... can back me up here...), and the literal translation is "powerful". But I think that in this context, "powerful" overstates the intention of saying "higher performing", which is IMHO too wordy. I think that just about EVERYONE understands what is meant when one applies the English suffix "-ant" to a well understood verb.
-Nick
This posting is provided “AS IS” with no warranties, and confers no rights. You assume all risk for your use. © 2001 Microsoft Corporation. All rights reserved.
|
|
|
|
 |
|
 |
Hello Nick,
I did understand what you meant by 'performant', in fact I was confused for a few seconds and wondered whether there actually was a such a word in English. I had to type that word into MS Word to realize that it was a non-existant word. Anyway whether it's French or not, I sorta liked that word. And I have used it too.
Thanks for the info anyway,
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
 |
|
 |
<TimTheToolMan>
Uhhroh?
</TimTheToolMan>
You mean like:
Playant?
Programant?
Developant?
Wankant?
If I'm not completely mistaken, when you add "ant" to a verb, it turns the word into a noun, and means "one who ____". Performant, in that sense, would mean one who performs. Unfortunately, it's not quite as widely used as you imply...
Complainant, disputant, combatant, etc. These are valid uses.
But I, like Nish, understood what you meant (until you blamed the French for your misunderstanding).
I just really need a nap.
J
"I am wise enough to therefore not spout my ill informed opinion as if it were remotely related to fact." - Christian Graus
|
|
|
|
 |
|
 |
Jamie Hale wrote:
until you blamed the French for your misunderstanding).
Yeah, that part was confusing. He also mentioned Canadians. Do those cricket-ignorant candians speak French as well?
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
 |
|
 |
Nish [BusterBoy] wrote:
Do those cricket-ignorant candians speak French as well?
This cricket-ignorant Canadian speaks enough French to amuse people at parties, but that's about it.
Il'y a des elephantes dans mon frigo.
J
"I am wise enough to therefore not spout my ill informed opinion as if it were remotely related to fact." - Christian Graus
|
|
|
|
 |
|
 |
Jamie Hale wrote:
This cricket-ignorant Canadian speaks enough French to amuse people at parties, but that's about it.
I see.
Jamie Hale wrote:
Il'y a des elephantes dans mon frigo.
And this one's prolly a canadian joke translated to french
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
 |