Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1012533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:57:38+00:00 2026-05-16T09:57:38+00:00

I have a function that I want to use as an event handler: void

  • 0

I have a function that I want to use as an event handler:

void singleFrameEventHandler(void) {
    SetEvent(g_hSingleFrameArrived);
}

However, when I try to register for the event:

iaframe->OnNewFrame += gcnew newFrame(&singleFrameEventHandler);

The following exception is raised:

An unhandled exception of type ‘System.NotSupportedException’ occurred in mscorlib.dll

Additional information: Serialization of global methods (including implicit serialization via the use of asynchronous delegates) is not supported.

Is there some way to get around this?


Edit:

I have changed the code so now the event handler is a method in a class. However, now I get a different exception:

An unhandled exception of type ‘System.Runtime.Serialization.SerializationException’ occurred in mscorlib.dll

Additional information: Unable to find assembly ‘BeamGage_Interface, Version=1.0.3882.24450, Culture=neutral, PublicKeyToken=null’.

If it’s relevant, the class definition looks like this:

[System::Serializable]
ref class FrameEventClass {
public:
    FrameEventClass(const char *newId, IAFrame ^ frame) : id(newId) {
        frame->OnNewFrame += gcnew newFrame(this, &FrameEventClass::frameEventHandler);
    }
private:
    const char *id;
    void frameEventHandler(void) {
        //Signal that the frame has arrived
        SetEvent(g_hSingleFrameArrived);
        //unregister for event
        IAFrame ^ frame = /* Code to get handle to frame object */;
        frame->OnNewFrame -= gcnew newFrame(this, &FrameEventClass::frameEventHandler);
        return;
    }
};

And here is how I register for the event:

gcnew FrameEventClass(id, iaframe);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T09:57:39+00:00Added an answer on May 16, 2026 at 9:57 am

    Type ‘FrameEventHandler’ … is not
    marked as serializable

    It’s not referring to your method singleFrameEventHandler, it’s referring to the delegate type FrameEventHandler.

    Probably something along the lines of public delegate void FrameEventHandler(); in the code for assembly BeamGage_Interface.

    update for question update
    From this page (can’t find the referenced msdn page)

    The common language runtime does not
    support serialization of global
    methods, so delegates cannot be used
    to execute global methods in other
    application domains.

    Other CLR languages (c# etc) don’t support global methods so you can’t use them with the CLR.

    Your solution (I believe) is to wrap singleFrameEventHandler (or maybe g_hSingleFrameArrived, I can’t tell from your snippets) in a class and pass the instance method instead. Something like (forgive my lack of recent c++ usage, I may make mistakes)

    class MyFrameEventHandler
    {
        public:
            void singleFrameEventHandler(void){
                SetEvent(g_hSingleFrameArrived);
            }
    }
    // Usage
    MyFrameEventHandler handler;
    iaframe->OnNewFrame += gcnew newFrame(&handler.singleFrameEventHandler);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 515k
  • Answers 515k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can implement the singleton pattern. One option is using… May 16, 2026 at 6:31 pm
  • Editorial Team
    Editorial Team added an answer You can use editedItemPosition property for this. Setting this property… May 16, 2026 at 6:31 pm
  • Editorial Team
    Editorial Team added an answer TL;DR: y = 2.408 * len(var_text) Lets assume that your… May 16, 2026 at 6:30 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have an arbitrary number of files that I need to load in an
I have some code that uses JavaScript templates to create some HTML, including some
I have a long-running console-based application Sender that sends simple text to STDOUT using
I have my object tracking the mouse using the onmousemove event. But I would
I have an anchor tag on my page that toggles between active and cancelled
I have a class which exposes literally dozens of events(before you get of on
I have a need to display a custom form instead of the default inspector
In Flash Professional CS4, I get migration issue warnings when I use mouse/keyboard input
I am creating a simple UI toolbar component in Haxe for use in a
I am working on the multifile uploader, and want to set the upload directory

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.