473,765 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reach managed c++ Enum from C#

I'm trying to use an enum created in Managed c++ in a C# project. I can reach
the enums name, i.e.

namespace MyNS
{
public enum MyEnum
{
EOne,
ETwo
};
}

in C++ makes me able to reach MyNS, but not MyNS.EOne. Why?
Mar 6 '07 #1
3 2394
Presumably you need to use MyNS.MyEnum.EOn e. In using enum values you need
to use <enum_type_name >.<valueand can't access <valuedirectl y.

"Joachim" <Jo*****@discus sions.microsoft .comwrote in message
news:92******** *************** ***********@mic rosoft.com...
I'm trying to use an enum created in Managed c++ in a C# project. I can
reach
the enums name, i.e.

namespace MyNS
{
public enum MyEnum
{
EOne,
ETwo
};
}

in C++ makes me able to reach MyNS, but not MyNS.EOne. Why?

Mar 6 '07 #2
Thank you Clive,

However, I have tried that too and it doesn't work.

Regards,
Joachim
"Clive Dixon" wrote:
Presumably you need to use MyNS.MyEnum.EOn e. In using enum values you need
to use <enum_type_name >.<valueand can't access <valuedirectl y.

"Joachim" <Jo*****@discus sions.microsoft .comwrote in message
news:92******** *************** ***********@mic rosoft.com...
I'm trying to use an enum created in Managed c++ in a C# project. I can
reach
the enums name, i.e.

namespace MyNS
{
public enum MyEnum
{
EOne,
ETwo
};
}

in C++ makes me able to reach MyNS, but not MyNS.EOne. Why?


Mar 7 '07 #3
"Joachim" <Jo*****@discus sions.microsoft .comwrote in message
news:92******** *************** ***********@mic rosoft.com...
I'm trying to use an enum created in Managed c++ in a C# project. I can reach
the enums name, i.e.

namespace MyNS
{
public enum MyEnum
{
EOne,
ETwo
};
}

in C++ makes me able to reach MyNS, but not MyNS.EOne. Why?

Because you have declared a *native* enum. You'll have to declare a managed enum to be
usable in other managed code.
Try this:
public enum class MyEnum
or..
public enum struct MyEnum

Willy.

Mar 7 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1683
by: sach | last post by:
Hi, I get this error error C3181: invalid operand for __typeof, expected a fully defined managed type Whenever I try to use Enum in VC++ .NET, which is actually defined in my VC++ library (unmanaged code) Is there any way so that I can perfom "Enum::GetName" on the Enum of unmanaged code? Please suggest
5
3872
by: Alan Cobb | last post by:
Hi, In the managed C++ class below I get compile warning C4677 from VS2003. "signature of non-private function contains assembly private type", even though the managed enum is public. I have to drop the "enum" keyword from my member variable declaration to keep the compiler happy. Shouldn't I technically be able to use the "enum" keyword without a warning?
1
1275
by: Bae,Hyun-jik | last post by:
Is there any way to port legacy C++ enum to managed object? For example, let's assume there is a C++ header file(we cannot modify it, because it is updated by other vendor). It has a enum definition like this. enum AAA { a,b,c }; Assuming that we made a managed DLL whose namespace id MyLib. I tried several way such as typedef __gc AAA MyAAA;
3
1957
by: Tommy Svensson \(InfoGrafix\) | last post by:
I've been instructed to work againt a huge unmanaged C++ API from a C# application. Now, the only way, as I've understood it, is to go the Managed Extensions for C++ way. This means I have to write a wrapper between unmanaged API and my managed app. Now on to the question: If there's an unmanaged API class called X with a defined method
0
3347
by: Ewart MacLucas | last post by:
generated some WMI managed classes using the downloadable extensions for vs2003 from mircrosoft downloads; wrote some test code to enumerate the physicall processors and it works a treat, but a question.. The code fails with the error that: "Additional information: COM object that has been separated from its underlying RCW can not be used." if I make a call to pc.Count before iterating though the objects. Dim d As New...
3
12271
by: Cmtk Software | last post by:
I'm trying to define an enum which will be used from unmanaged c++, C++/CLI managed c++ and from C#. I defined the following enum in a VS dll project set to be compiled with the /clr switch: public enum Days { Sunday };
1
2509
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
I'm trying to use an enum created in Managed c++ in a C# project. I can reach the enums name, i.e. namespace MyNS { public enum MyEnum { EOne, ETwo };
11
3200
by: briankirkpatrick | last post by:
Forgive me if my post seems a little amateurish... I'm requesting assistance from some of you smart folks out there to get the managed calls write that meet the specification in the esa.h for Esa_Init. When I make a call, VS2005 reports "AccessViolationException" and refers to the 4th parameter (EsaT_State_Handle). I don't know how to define nor pass this reference correctly to the legacy DLL. What am I doing wrong? Thanks in...
3
8005
by: Dean Mitchell | last post by:
Hi everyone, We have a c++ server application that we are writing a GUI client application for. To save our time and to avoid duplicating all the code and functionality that already exists in c++ classes I am building a managed c++ assembly around these classes so that a c# program can use them. The problem is that alot of these c++ classes use enums, I would like to make these visible to the c# application but I cannot find a way to...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9955
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.