|
Adding the #pragma directive succeeded! Thank you.
As follow up, can you tell me why the .lib has to be added to a project for exporting unmanaged classes compiled with /clr, but not if the DLL was build without CLR support? Or why in a /clr build, the .lib is required for importing unmanaged classes but not for importing stand-alone, unmanaged functions (that were surrounded with the "#pragma unmanaged" directive)?
Also, then, does the #using<> directive only pertain to managed code? Earlier I had tried adding the code #using < CliLib.dll >, but that did not help. Only referring to the .lib file solved the problem.
Could you direct me to any useful articles related to all of this?
Thanks again.
|
|
|
|
|
Xpnctoc wrote: As follow up, can you tell me why the .lib has to be added to a project for exporting unmanaged classes compiled with /clr, but not if the DLL was build without CLR support? Or why in a /clr build, the .lib is required for importing unmanaged classes but not for importing stand-alone, unmanaged functions (that were surrounded with the "#pragma unmanaged" directive)?
The lib is needed in bith scenarios. It's just that, without the /clr the VS IDE automatically uses the lib (possibly because you have a project dependency set appropriately).
It should really do the same for /clr too - but it looks like the IDE team overlooked doing that. This'd be a minor-level bug I suppose.
Xpnctoc wrote: Also, then, does the #using<> directive only pertain to managed code? Earlier I had tried adding the code #using < CliLib.dll >, but that did not help. Only referring to the .lib file solved the problem.
#using is used to access a managed assembly (including a mixed-mode assembly). It imports the managed meta data that allows us to use those types in our calling app.
It has nothing to do with exported native types.
|
|
|
|
|
I get it now. I didn't even think of the project dependency settings, and you are absolutely right that I do have a dependency set. I'm so accustomed to the IDE taking care of the LIB links that I just never even thought of it.
Thank you so much for all of your help.
|
|
|
|
|
hey guys, just a very quick question. How od i bring up a msgbox with c++. cant seem to find anyhting on the site.
Thank you VERY much.
- Droz -
___ ___
/\/\ /\ | |
|
|
|
|
|
AfxMessageBox if you're using MFC, MessageBox if you're not.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: AfxMessageBox if you're using MFC, MessageBox if you're not.
And MessageBox::Show if you are using WinForms.
|
|
|
|
|
Thank you for your time.
- Droz -
___ ___
/\/\ /\ | |
|
|
|
|
|
But who does such a thing ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: But who does such a thing ?
Come on, CG, you and I know that there are 100s of 1000s of C++ devs using WinForms with C++/CLI
|
|
|
|
|
Yeah, probably. But only because they download Express, or perhaps they live in fairyland.... :P
Ooops - this was in the managed form. My bad...
-- modified at 18:15 Friday 18th August, 2006
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
This is one of the weirdest things I've ever seen. And its been very tricky to nail down.
We instantiate a class (foo *somefoo = new foo() ) using 'new' and get a pointer to that class.
Later in code, witihin a function of another class, we 'new' a new piece of memory (char *buff = (char*) new char [buffSize]) VERY oddly, this 'new' is returning the address of "somefoo" we instantiated earlier and not a new piece of memory.
Any ideas why this is happening? Or how we can avoid this? Remarkably, its happening at the same point in code EVERY time, although we use new everywhere. This was a pain in the a#$ to find.
Help please!?!?!?!?!?
-C
|
|
|
|
|
The most obvious answer is that the particular instance of somefoo is being deleted and returning that address to the available heap prior to the char array being allocated.
led mike
|
|
|
|
|
First: how is this a C++/CLI question?
Second: what? How is it a file if it is not saved?
led mike
|
|
|
|
|
hi,
i am using Visual C++ toolkit 2003.
i am writing a windows forms application.
if i click a button , it has to call an win 32 api from windows.h, say MessageBox(),
i included #include windwos.h
now it is giving an ambiguity error WinMain is already defined,
how to get out of this, even i tried the order of
#using mscorlib.dll
# include windows.h
// i am having some assumption or workarounds for this,, but i need a solution ??
// because i am intersted in discussing about this ..
// warm welcome for the discussion
^-^
@|@
- redCat
|
|
|
|
|
Hello friends,
I have downloaded libjingle application which uses
third party component GIPS. Can we replace third party component GIPS by any
other third party component. Which must be available freely.
Thanks in Advance.
Rahul Kulkarni
|
|
|
|
|
I have an unmanaged C++ dll which is an MFC shared DLL that has functions in it to initialize sockets and do other ethernet related things. I have built a managed C++ wrapper project which is also an MFC shared DLL, compiled with /clr that calls functions in the unmanaged dll. Then I have a C# project which instantiates a member of the wrapper class to access the unmanaged functions.
One of the functions in the unmanaged dll creates a new CAsyncSocket, checks to see if AfxSocketInit is successful, and if so, calls Create to create a new socket. When I call this function through my wrapper from C#, I get a debug assertion when Create is called. The call stack trace indicates that the problem is in a call to AfxGetInstanceHandle.
I've done a lot of reading about the use of AfxGetInstanceHandle, but I can still not find any solution to this problem.
If anyone can help me out, I'd really appreciate it.
|
|
|
|
|
|
According to this, using AFX_MANAGE_STATE isn't the answer...
http://msdn2.microsoft.com/en-us/library/30c674tx.aspx[^]
It says in there:
"The AFX_MANAGE_STATE macro should not be used in regular DLLs that statically link to MFC or in extension DLLs. "
My unmanaged dll is an extension DLL, and when I attempt to use AFX_MANAGE_STATE, I get dllmain linker errors...
Does anyone else have any other ideas? I'm really stuck here and would appreciate any advise. Thank you so much,
Doreen
|
|
|
|
|
see if this article[^] will provide the details you are missing.
led mike
|
|
|
|
|
I'd like to open 500 files with OpenFileDialog with enabled multiselect. But it failes to do it throwing exception? What property to modify to open a lot of files?
9ine
|
|
|
|
|
i want to connect sql server 2000 & mysql 5.0 through c++ on wndows plateform.
can any one help me in this regards?
|
|
|
|
|
Google knows.
BTW, this is the MANAGED C++ forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi all,
I am currently working on Serial Interface between a control box and PC and want to send/receive double values from Pc to the box as 8 uint8 values since the box only accepts in uint8 form.
For that i thought as follows : to get that double value (64 bits) in binary form and get the last 8 bits with &(and) operator and shifting bits to right till all bits are finished,namely :
double var;
char var2send[8]; % in array
var2send[0]= var & 0x00000000000000ff % last 8 bits with & operator
var>>8; %shifting bits
var2send[1]= var & 0x00000000000000ff
var>>8;
.
. % and sending this array as output
.
But in this code, i received an error that says i cant use double with & operators so that must be converted 64 bit long form!! How can i manage to do this?? or anyone has better way or suggestion?
I hope i could clearly explain my problem.
I would be very pleased if you could help me!
Thanks a lot!
Cahit
|
|
|
|
|
Yes, binary operations only work with integers. Multiply by whatever number of decimals you want, then cast to int. BTW, this is the wrong forum, this is not a managed C++ question
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
oh sorry, i deliver my message in visual c++ forum then!
|
|
|
|