473,396 Members | 1,898 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,396 software developers and data experts.

Error configuring event listener in C++ with .NET CLR support (managed and unmanaged

Hi All,
I am using AForge library to capture live video stream from an IP camera. Initially, I tested my task in a simple C# application but I should convert my code into my existing MFC C++ application. I made some progress as the following:
1. I configured the project to become compatible with .NET common run-time language
a. Right click the project and select ‘Properties’.
b. From the left panel, I selected ‘Configuration Properties’
c. Select ‘General’.
d. In ‘Common Language Runtime Support’ list select Common Language Runtime Support (/clr))
2. I added the necessary AForge DLLs to the projct. (Right click the project and select ‘References’)
3. The following is a part of my code in mfc_testDlg.h
Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <vcclr.h> //to use gcroot
  3. using namespace AForge::Controls;
  4. using namespace AForge::Video;
  5.  
  6. class Cmfc_testDlg : public CDialog
  7. {
  8. public:
  9.     gcroot<AForge::Video::MJPEGStream^> VideoStream;
  10.         void temp();
  11.     void VideoStream_NewFrame(System::Object^  sender, AForge::Video::NewFrameEventArgs^ eventArgs);
  12. }
4. The following is a part of my code in mfc_testDlg.cpp
Expand|Select|Wrap|Line Numbers
  1. using namespace AForge::Controls;
  2. using namespace AForge::Video;
  3. void Cmfc_testDlg::temp()
  4. {    
  5.     VideoStream = (gcnew AForge::Video::MJPEGStream());
  6.     VideoStream->Source = "http://IP Address/img/mjpeg.cgi";
  7.     VideoStream->Login = "User Name";
  8.     VideoStream->Password = "Password";
  9.     VideoStream->NewFrame += gcnew AForge::Video::NewFrameEventHandler(this, &Cmfc_testDlg::VideoStream_NewFrame);
  10.  
  11.     VideoStream->Start();
  12. }
  13.  
  14. void Cmfc_testDlg::VideoStream_NewFrame(System::Object^  sender, AForge::Video::NewFrameEventArgs^ eventArgs)
  15. {
  16.     //Write Some Code
  17. }
My code generates an error due to the line:
Expand|Select|Wrap|Line Numbers
  1. VideoStream->NewFrame += gcnew AForge::Video::NewFrameEventHandler(this, &Cmfc_testDlg::VideoStream_NewFrame);
This is the generated error:
Expand|Select|Wrap|Line Numbers
  1. error C3364: 'AForge::Video::NewFrameEventHandler' : invalid argument for delegate constructor; delegate target needs to be a pointer to a member function
It seems I couldn’t register the event listener properly in C++/with .NET CLR support. Actually I am not expert in C++ but I am fairly experience in C# and Java. Can you please suggest what I should change in my code?

Best Regards,
Abdullah
Jul 30 '12 #1
1 2533
weaknessforcats
9,208 Expert Mod 8TB
Operators like
Expand|Select|Wrap|Line Numbers
  1. new
or
Expand|Select|Wrap|Line Numbers
  1. gcnew
return an address or a reference to a object so the += in your gcnew line looks suspicious. Unfortunately, I am not an expert with gcnew so I may be off base.
Jul 30 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Neil Cherry | last post by:
I have to modifiy a program which uses a serial interface and event listeners. The modification entails adding support for connecting to a terminal server via an IP address and port number instead...
4
by: | last post by:
I am stuck in a situation and I do believe that this should work, but it doesn't. I have a unmanaged dll, that uses MFC. This works great. Now I recompile the unmanaged dll so it contains...
3
by: JoeProgrammer | last post by:
A couple of questions re. managed vs. unmanaged code. 1. I know this depends on the app, but how much faster is unmanaged code vs. managed code? Is there an average figure for this? 2. Is it as...
3
by: Steve | last post by:
I have former VC++ 6.0 application which was ported to .NET. Now we continue to develop this app under VS.NET. The app now contains both managed and unmanaged classes. Now I have a problem with...
13
by: DD | last post by:
I'm puzzled how to mix managed/unmanaged C++ in the following scenario: Unmanaged ------------ Callback listener class with method that should call an event in managed Form1. Initialization...
6
by: nicolas.hilaire | last post by:
Hi all, i'm not totally clear with some concepts about managed and unmanaged code. I'm asking myself some questions : - i've a MFC app, i want to use the framework dotnet by switching to...
6
by: Vijay | last post by:
Hi, I am faced with the following common managed/unmanaged C++ interop problem: - I have a .NET form that acts as a front end GUI to a processing engine in the background. The processing...
6
by: Jeremy | last post by:
I want each instance of an object to be able to listen for input events. When the event occurs, a method of the object should be called, such that "this" is in scope and refers to the object...
7
by: A n g l e r | last post by:
Hi all. Can you please tell me if you have any problems to use managed C++ DLL libraries that wrap some code from unmanaged external DLL 32 bit libraries? If you called such managed 32 bit DLL...
0
by: hanthehead | last post by:
In order to use a C# dll from our unmanaged C++ project I have created a mixed managed\unmanaged c++ dll. This dll is passed an unmanaged class which contains vector<CDBRecord> m_vecRecords member...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.