Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
C++
#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);
		}
	}</system.windows.forms.dll></mscorlib.dll>
Posted

see Compiler Error C3767[^] it tells you not only why you get the error but also how to resolve it.
 
Share this answer
 
Comments
Shashidhar Kamath 20-Oct-11 17:47pm    
it says " native types are now private by default in a /clr compilation " I still don't understand in my example what is private ?
Simon Bang Terkildsen 20-Oct-11 18:07pm    
Do you get the line number of the line that fails? If so which line is it?

This might be of interest make_public
Espen Harlinn 23-Oct-11 17:59pm    
My 5, seems like a lost cause though ...
Simon Bang Terkildsen 25-Oct-11 14:40pm    
Yeah, I guess the OP figured it out.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900