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

  • SEARCH
  • Home
  • 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 7687391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:41:35+00:00 2026-05-31T19:41:35+00:00

I am trying to fire an event from a unmanaged function using a pointer

  • 0

I am trying to fire an event from a unmanaged function using a pointer to managed object. I get the following error:

error C3767: 'ShashiTest::test::OnShowResult::raise': candidate function(s) not accessible

How ever I can call regular function ShowMessage without any issue?

#pragma once

#using<mscorlib.dll>
#using<System.Windows.Forms.dll> 

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Diagnostics;
using namespace System::Windows::Forms;

namespace ShashiTest {
    public delegate void ShowResult(System::String^);

    public ref class test
    {
    public:
        event ShowResult^ OnShowResult;
        test(void)
        {
        };
        void ShowMessage()
        {
            MessageBox::Show("Hello World");
        }
    };

    class ManagedInterface
    {
    public:
        gcroot<test^> m_test;
        ManagedInterface(){};
        ~ManagedInterface(){};

        void ResultWindowUpdate(std::string ResultString);
    };
}

void ShashiTest::ManagedInterface::ResultWindowUpdate(std::string ResultString)
{
    if(m_test)
    {
        System::String ^result = gcnew system::String(ResultString.c_str());
        m_test->OnShowResult(result);
    }
}
  • 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-31T19:41:37+00:00Added an answer on May 31, 2026 at 7:41 pm

    You can do this by manually defining the event, and changing the access level of the raise() portion to internal or public. (The default is either protected or private — see the post by ildjarn at http://social.msdn.microsoft.com/forums/en-US/vclanguage/thread/ff743ebd-dba9-48bc-a62a-1e65aab6f2f9 for details.)

    The following compiled for me:

    public ref class test
    {
    public:
        event ShowResult^ OnShowResult {
            void add(ShowResult^ d) {
                _showResult += d;
            }
            void remove(ShowResult^ d) {
                _showResult -= d;
            }
        internal:
            void raise(System::String^ str) {
                if (_showResult) {
                    _showResult->Invoke(str);
                }
            }
        };
        test(void)
        {
        };
        void ShowMessage()
        {
            MessageBox::Show("Hello World");
        }
    private:
        ShowResult^ _showResult;
    };
    

    An alternative would be to define a helper function that would fire the event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get an event to fire whenever a choice is made from
i am trying to write a custom event which should get fire when user
I'm trying to fire a function when the keyup event happens. This works fine
I am having problems trying to get a rowcommand event to fire in a
I am using directions from here: http://msdn.microsoft.com/en-us/library/ms257351(VS.80).aspx to create a managed event class. Here's
I'm trying to fire an event from an external HTML page opened inside of
I'm trying to fire a click event on my select options. This is working
I am trying to write something that will fire an event anytime the hard
I'm trying to have a jQuery UI event fire only if it meets the
I am new to jQuery and am trying to fire a function on a

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.