that's why I have the following:
/// managed_cmd.h (managed C++ bridge)
namespace bridge
{
public <<<<<<======== see this
#include "Command.h"
}
Main Topics
Browse All TopicsI have this project split into three parts:
1. Unmanaged C++ doing most of the internal processing
2. C# serving as UI
3. managed C++ bridging the two
Now I want simple types (enums and structs) defined in unmanaged C++ to be visible to C# project. and I don't want to copy-paste. when one definition changes I have to apply the changes to the other. and if I miss something I may not find it out until runtime.
So I came up with the following trick
(see the attached code)
The problem is that in C# I don't see any values in the Command enum. so in C# I cannot do things like
sendCommand(bridge.Command
Although in managed C++ it compiles fine. (it doesn't show up in intellisense but that is a minor concern)
if (cmd == bridge::Command::MOVE_LEFT
Why is the enum empty in C#?
Is there a better way to share types between managed and unmanaged environments without doing too much manual maintenance?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Just found the solution. see http://msdn.microsoft.com/
enum header files are now changed to look like
MOVE_LEFT,
MOVE_RIGHT,
etc.
i.e. no enum type names or curly braces
and included like this:
// unmanaged:
namespace native_proj
{
enum Command {
#include "Command.h"
};
}
// managed:
namespace bridge
{
enum class Command { <<< note the difference "enum class" vs "enum"
#include "Command.h"
};
}
Business Accounts
Answer for Membership
by: ragi0017Posted on 2008-10-11 at 11:01:11ID: 22694789
if following is the definition of the enum in the unmanaged c++ file then what will be the access modifier for that enum - as far as i remember it should be equivalent to internal in C# - in that case how can you access the type outside the assembly or interop in your case (i am just guessing as in C# it will not work outside the assembly as it will be given the default access modifier of internal)
enum Command {
MOVE_LEFT,
MOVE_RIGHT,
etc.
};