Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following managed class

namespace Managed_DLL
{
public ref class AController
{    
public:        
       delegate void didChangeListenerStatus(tListenerStatus status);

....};

// header file
#if defined(_MANAGED)
namespace Managed_DLL
{
#define ENUMKEYWORD public enum
#else
#define ENUMKEYWORD typedef enum
#endif
ENUMKEYWORD tListenerStatus
{    
kListenerStopped,    
kListenerRunning,    
kListenerFailed} ;
}


I have defined the _MANAGED in the dll preprocessor defines
In C# app I have defined the didChangeListenerStatus in one of classes as


using Managed_DLL
....
public void didChangeListenerStatus(tListenerStatus status)        
{            
Console.WriteLine(" didChangeListnerStatus called");        
}
When I compile the C# app it gives the following error


Error   4   'tListenerStatus' is inaccessible due to its protection level   Error   3   Inconsistent accessibility: parameter type 'tListenerStatus' is less accessible than method 'ADemo.ViewController.didChangeListenerStatus(tListenerStatus) 
Posted

Just locate the declaration of the type tListenerStatus and make it public.


(Remember: there is not inter-operation problems between C# and C++/CLI, the same stands for all .NET languages. However, there is one special feature of C++/CLI: the "value semantic" for reference types, which is not available in other languages. In other words, you can only use "^" reference types for inter-operation.)

—SA
 
Share this answer
 
I don't think your preprocessor directive is working, and as was pointed out in the other answer, you don't need it for a purely managed class. Just make your header file declaration as follows:
namespace Managed_DLL
{
    public enum tListenerStatus
    {    
        kListenerStopped,
        kListenerRunning,
        kListenerFailed
    };
}
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 23-Mar-11 15:20pm    
Please read carefully: OP does not use unmanaged at all. There is not problem.
--SA
Sergey Alexandrovich Kryukov 23-Mar-11 16:23pm    
Now it's correct.
--SA

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