How to access ENUM from a DLL

V

vijay.gandhi

Hi,

I have a DLL (created in C++/CLI), that has a public enum.

For example:
namespace Utilities {
public enum DISTANCE_TYPE
{
a,
b,
c
};
}

This DLL was imported to another C++/CLI project. While I can see the
DISTANCE_TYPE in the 'object browser', I am not able to access it ( I
use: 'DISTANCE_TYPE nDisType;' in my code). The Visual Studio
editor's Intellisense does not list DISTANCE_TYPE as a member of
Utilities, and even the compiler throws an error that DISTANCE_TYPE is
undeclared. However, when I redeclare it in my new project, the
compiler throws an error that the type DISTANCE_TYPE is redefined.

Is there any other way to use the enum's in the DLL?

Thank you very much,
Vijay.
 
J

Jochen Kalmbach [MVP]

Hi vijay!
I have a DLL (created in C++/CLI), that has a public enum.

For example:
namespace Utilities {
public enum DISTANCE_TYPE
{
a,
b,
c
};
}

This DLL was imported to another C++/CLI project.

What do you mean with "imported"?

You need to "add a reference" to this DLL-Assembly. That's all; then you
can use all public symbols.


--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
B

Ben Voigt [C++ MVP]

Hi,

I have a DLL (created in C++/CLI), that has a public enum.

For example:
namespace Utilities {
public enum DISTANCE_TYPE

You need "enum class" to get a .NET compatible enum.
 
V

vijay.gandhi

Jochen, thanks for your reply. Yes, by imported I meant adding a
reference. It still doesn't show up.

Ben, thank you. Just read about 'enum class.'

Vijay.
 
B

Ben Voigt [C++ MVP]

Jochen, thanks for your reply. Yes, by imported I meant adding a
reference. It still doesn't show up.

Ben, thank you. Just read about 'enum class.'

Glad to be helpful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top