Error with compiling code..
-
hello everythings gos good with the code Below, but when i try to make object (MessageQueue TheQueue = new MessageQueue;), it give me an errors says : Error 1 error C3821: 'System::Messaging::MessageQueue': managed type or function cannot be used in an unmanaged function c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 2 error C3624: 'System::ComponentModel::Component': use of this type requires a reference to assembly 'System' c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 3 error C3821: 'System::Messaging::MessageQueue': managed type or function cannot be used in an unmanaged function c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 4 error C2750: 'System::Messaging::MessageQueue' : cannot use 'new' on the reference type; use 'gcnew' instead c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 5 error C3642: 'System::Messaging::MessageQueue::MessageQueue(void)' : cannot call a function with __clrcall calling convention from native code c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 6 error C3175: 'System::Messaging::MessageQueue::MessageQueue' : cannot call a method of a managed type from unmanaged function 'SendToQueue' c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 7 error C2664: 'System::Messaging::MessageQueue::MessageQueue(System::String ^)' : cannot convert parameter 1 from 'System::Messaging::MessageQueue *' to 'System::String ^' c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 ------------------------------------------------------ ------------------------------------------------------
#include "stdafx.h" #using <system.messaging.dll> using namespace System::Messaging; #ifdef _MANAGED #pragma managed(push, off) #endif BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } int _stdcall Sum(int inA, int inB) { return (inA + inB); } int _stdca
-
hello everythings gos good with the code Below, but when i try to make object (MessageQueue TheQueue = new MessageQueue;), it give me an errors says : Error 1 error C3821: 'System::Messaging::MessageQueue': managed type or function cannot be used in an unmanaged function c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 2 error C3624: 'System::ComponentModel::Component': use of this type requires a reference to assembly 'System' c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 3 error C3821: 'System::Messaging::MessageQueue': managed type or function cannot be used in an unmanaged function c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 4 error C2750: 'System::Messaging::MessageQueue' : cannot use 'new' on the reference type; use 'gcnew' instead c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 5 error C3642: 'System::Messaging::MessageQueue::MessageQueue(void)' : cannot call a function with __clrcall calling convention from native code c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 6 error C3175: 'System::Messaging::MessageQueue::MessageQueue' : cannot call a method of a managed type from unmanaged function 'SendToQueue' c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 7 error C2664: 'System::Messaging::MessageQueue::MessageQueue(System::String ^)' : cannot convert parameter 1 from 'System::Messaging::MessageQueue *' to 'System::String ^' c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 ------------------------------------------------------ ------------------------------------------------------
#include "stdafx.h" #using <system.messaging.dll> using namespace System::Messaging; #ifdef _MANAGED #pragma managed(push, off) #endif BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } int _stdcall Sum(int inA, int inB) { return (inA + inB); } int _stdca
Here agin u chose an an unmanged project type insted of a managed one. Hope my reply to ur post below will make things clear. rgds...milton
-
hello everythings gos good with the code Below, but when i try to make object (MessageQueue TheQueue = new MessageQueue;), it give me an errors says : Error 1 error C3821: 'System::Messaging::MessageQueue': managed type or function cannot be used in an unmanaged function c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 2 error C3624: 'System::ComponentModel::Component': use of this type requires a reference to assembly 'System' c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 3 error C3821: 'System::Messaging::MessageQueue': managed type or function cannot be used in an unmanaged function c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 4 error C2750: 'System::Messaging::MessageQueue' : cannot use 'new' on the reference type; use 'gcnew' instead c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 5 error C3642: 'System::Messaging::MessageQueue::MessageQueue(void)' : cannot call a function with __clrcall calling convention from native code c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 6 error C3175: 'System::Messaging::MessageQueue::MessageQueue' : cannot call a method of a managed type from unmanaged function 'SendToQueue' c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 7 error C2664: 'System::Messaging::MessageQueue::MessageQueue(System::String ^)' : cannot convert parameter 1 from 'System::Messaging::MessageQueue *' to 'System::String ^' c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 ------------------------------------------------------ ------------------------------------------------------
#include "stdafx.h" #using <system.messaging.dll> using namespace System::Messaging; #ifdef _MANAGED #pragma managed(push, off) #endif BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } int _stdcall Sum(int inA, int inB) { return (inA + inB); } int _stdca
You've told the compiler that
SendToQueue()
is unmanaged, yet you're trying to use managed code in it. And it should beMessageQueue^ theQueue = gcnew MessageQueue;
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
hello everythings gos good with the code Below, but when i try to make object (MessageQueue TheQueue = new MessageQueue;), it give me an errors says : Error 1 error C3821: 'System::Messaging::MessageQueue': managed type or function cannot be used in an unmanaged function c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 2 error C3624: 'System::ComponentModel::Component': use of this type requires a reference to assembly 'System' c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 3 error C3821: 'System::Messaging::MessageQueue': managed type or function cannot be used in an unmanaged function c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 4 error C2750: 'System::Messaging::MessageQueue' : cannot use 'new' on the reference type; use 'gcnew' instead c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 5 error C3642: 'System::Messaging::MessageQueue::MessageQueue(void)' : cannot call a function with __clrcall calling convention from native code c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 6 error C3175: 'System::Messaging::MessageQueue::MessageQueue' : cannot call a method of a managed type from unmanaged function 'SendToQueue' c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 Error 7 error C2664: 'System::Messaging::MessageQueue::MessageQueue(System::String ^)' : cannot convert parameter 1 from 'System::Messaging::MessageQueue *' to 'System::String ^' c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\dll_from2005\MessageQueue\MessageQueue\MessageQueue.cpp 26 ------------------------------------------------------ ------------------------------------------------------
#include "stdafx.h" #using <system.messaging.dll> using namespace System::Messaging; #ifdef _MANAGED #pragma managed(push, off) #endif BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } int _stdcall Sum(int inA, int inB) { return (inA + inB); } int _stdca
ALQallaf wrote:
MessageQueue TheQueue = new MessageQueue;
As Mike said, you need to use
gcnew
and notnew
. Alternatively you can use stack semantics.MessageQueue TheQueue;
TheQueue.Func(...);Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
The Ultimate Grid - The #1 MFC grid out there! -
You've told the compiler that
SendToQueue()
is unmanaged, yet you're trying to use managed code in it. And it should beMessageQueue^ theQueue = gcnew MessageQueue;
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
ALQallaf wrote:
MessageQueue TheQueue = new MessageQueue;
As Mike said, you need to use
gcnew
and notnew
. Alternatively you can use stack semantics.MessageQueue TheQueue;
TheQueue.Func(...);Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
The Ultimate Grid - The #1 MFC grid out there! -
ALQallaf wrote:
i tryed your syntax , but still having an errors nothing changed
Check the following :
- Are you using the old syntax? You cannot use C++/CLI with the old syntax mode.
- Have you included references to all required assemblies?
- Are you inside a #pragma unmanaged block? If so, you cannot (obviously) do managed stuff in there.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
The Ultimate Grid - The #1 MFC grid out there! -
nothing changes still have errors when i place MessageQueue^ theQueue = gcnew MessageQueue; inside my function SendToQueue()
You've told the compiler (via the
pragma
s) thatSendToQueue()
is unmanaged, yet you're trying to use managed code in it.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
You've told the compiler (via the
pragma
s) thatSendToQueue()
is unmanaged, yet you're trying to use managed code in it.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
Yes, exactly .. he was trying to call managed code from unmanaged function. He got fixed creating a new managed cpp project. rgds...milton
-
ALQallaf wrote:
i tryed your syntax , but still having an errors nothing changed
Check the following :
- Are you using the old syntax? You cannot use C++/CLI with the old syntax mode.
- Have you included references to all required assemblies?
- Are you inside a #pragma unmanaged block? If so, you cannot (obviously) do managed stuff in there.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
The Ultimate Grid - The #1 MFC grid out there! -
ALQallaf wrote:
i tryed your syntax , but still having an errors nothing changed
Check the following :
- Are you using the old syntax? You cannot use C++/CLI with the old syntax mode.
- Have you included references to all required assemblies?
- Are you inside a #pragma unmanaged block? If so, you cannot (obviously) do managed stuff in there.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
The Ultimate Grid - The #1 MFC grid out there!Nish he was trying to call managed dll from an unmanged win32 dll. thats why the err. rgds..milton.