I have a .cs file which is linked to several other projects. All my classes
in this file are defined as internal. I would like to have an enum defined
as well in the namespace but I get an error from one project that the
accessibility of the enum is less (public) than that of a method which
returns that's type.
What is the best way to define this enum without getting duplicate define
warnings or this error of less accessibility?
Thanks,
Joe 8 1718
So how exactly is the enum defined and are you trying to use it across
different projects and\or namespaces?
HTH
Ollie Riches
"Joe" <jb*******@noem ail.noemail> wrote in message
news:Oj******** ******@TK2MSFTN GP14.phx.gbl... I have a .cs file which is linked to several other projects. All my classes in this file are defined as internal. I would like to have an enum defined as well in the namespace but I get an error from one project that the accessibilit y of the enum is less (public) than that of a method which returns that's type.
What is the best way to define this enum without getting duplicate define warnings or this error of less accessibility?
Thanks, Joe
// In linked .cs
namespace something
{
public enum whatever {abc, def,};
}
// project A
public class ProjectA
{
public something.whate ver GetEnum()
{
return something.whate ver.abc;
}
}
// project B
private void CallProjectACla ss()
{
ProjectA a = new ProjectA();
a.GetEnum();
}
"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message
news:ew******** ******@TK2MSFTN GP15.phx.gbl... So how exactly is the enum defined and are you trying to use it across different projects and\or namespaces?
HTH
Ollie Riches
"Joe" <jb*******@noem ail.noemail> wrote in message news:Oj******** ******@TK2MSFTN GP14.phx.gbl...I have a .cs file which is linked to several other projects. All my classes in this file are defined as internal. I would like to have an enum defined as well in the namespace but I get an error from one project that the accessibility of the enum is less (public) than that of a method which returns that's type.
What is the best way to define this enum without getting duplicate define warnings or this error of less accessibility?
Thanks, Joe
That looks perfectly fine, it shoudl compile ok
Ollie
"Joe" <jb*******@noem ail.noemail> wrote in message
news:e%******** ********@TK2MSF TNGP14.phx.gbl. .. // In linked .cs namespace something { public enum whatever {abc, def,}; }
// project A public class ProjectA { public something.whate ver GetEnum() { return something.whate ver.abc; } }
// project B private void CallProjectACla ss() { ProjectA a = new ProjectA(); a.GetEnum(); }
"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message news:ew******** ******@TK2MSFTN GP15.phx.gbl... So how exactly is the enum defined and are you trying to use it across different projects and\or namespaces?
HTH
Ollie Riches
"Joe" <jb*******@noem ail.noemail> wrote in message news:Oj******** ******@TK2MSFTN GP14.phx.gbl...I have a .cs file which is linked to several other projects. All my classes in this file are defined as internal. I would like to have an enum defined as well in the namespace but I get an error from one project that the accessibility of the enum is less (public) than that of a method which returns that's type.
What is the best way to define this enum without getting duplicate define warnings or this error of less accessibility?
Thanks, Joe
It compiles fine but I get a warning about enum whatever being defined in 2
locations.
"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message
news:%2******** **********@TK2M SFTNGP12.phx.gb l... That looks perfectly fine, it shoudl compile ok
Ollie "Joe" <jb*******@noem ail.noemail> wrote in message news:e%******** ********@TK2MSF TNGP14.phx.gbl. .. // In linked .cs namespace something { public enum whatever {abc, def,}; }
// project A public class ProjectA { public something.whate ver GetEnum() { return something.whate ver.abc; } }
// project B private void CallProjectACla ss() { ProjectA a = new ProjectA(); a.GetEnum(); }
"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message news:ew******** ******@TK2MSFTN GP15.phx.gbl... So how exactly is the enum defined and are you trying to use it across different projects and\or namespaces?
HTH
Ollie Riches
"Joe" <jb*******@noem ail.noemail> wrote in message news:Oj******** ******@TK2MSFTN GP14.phx.gbl... I have a .cs file which is linked to several other projects. All my classes in this file are defined as internal. I would like to have an enum defined as well in the namespace but I get an error from one project that the accessibility of the enum is less (public) than that of a method which returns that's type.
What is the best way to define this enum without getting duplicate define warnings or this error of less accessibility?
Thanks, Joe
If I understand correctly, you have 2 projects, and a common c# file that
you have included in both projects. This might compile OK, but at runtime I
can see there being a conflict, since both assemblies contain a definition
for "Something.What ever". Even more problems could result if you had the
enum declared as internal, since internal essentially means "public, but
only inside this assembly".
Instead of including the c# file in both projects, create a 3rd shared
library projcet (say, common.dll) , and add a reference to that in the other
two projects, or more projects if need be. Your common enum - and any other
common classes - would go in there. That way, Project A and Project B would
be referencing the same definition for "Something.What ever".
Hope that makes sense!
Derrick
"Joe" <jb*******@noem ail.noemail> wrote in message
news:eq******** ******@TK2MSFTN GP10.phx.gbl... It compiles fine but I get a warning about enum whatever being defined in 2 locations.
"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message news:%2******** **********@TK2M SFTNGP12.phx.gb l... That looks perfectly fine, it shoudl compile ok
Ollie "Joe" <jb*******@noem ail.noemail> wrote in message news:e%******** ********@TK2MSF TNGP14.phx.gbl. .. // In linked .cs namespace something { public enum whatever {abc, def,}; }
// project A public class ProjectA { public something.whate ver GetEnum() { return something.whate ver.abc; } }
// project B private void CallProjectACla ss() { ProjectA a = new ProjectA(); a.GetEnum(); }
"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message news:ew******** ******@TK2MSFTN GP15.phx.gbl... So how exactly is the enum defined and are you trying to use it across different projects and\or namespaces?
HTH
Ollie Riches
"Joe" <jb*******@noem ail.noemail> wrote in message news:Oj******** ******@TK2MSFTN GP14.phx.gbl... >I have a .cs file which is linked to several other projects. All my >classes in this file are defined as internal. I would like to have an >enum defined as well in the namespace but I get an error from one >project that the accessibility of the enum is less (public) than that >of a method which returns that's type. > > What is the best way to define this enum without getting duplicate > define warnings or this error of less accessibility? > > Thanks, > Joe >
Hi Joe,
Does Derrick's reply make sense to you? To use a shared library dll, we
have to expose the classes in the assembly as public, not internal, or the
outside assembly can not use it. If you have any concern, please feel free
to feedback. Thanks
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Thanks Derrick. I don't know why I didn't create a separate library to begin
with. I already have like ~15.
"Derrick" <de***********@ hotmail.com> wrote in message
news:zd******** **********@news 20.bellglobal.c om... If I understand correctly, you have 2 projects, and a common c# file that you have included in both projects. This might compile OK, but at runtime I can see there being a conflict, since both assemblies contain a definition for "Something.What ever". Even more problems could result if you had the enum declared as internal, since internal essentially means "public, but only inside this assembly".
Instead of including the c# file in both projects, create a 3rd shared library projcet (say, common.dll) , and add a reference to that in the other two projects, or more projects if need be. Your common enum - and any other common classes - would go in there. That way, Project A and Project B would be referencing the same definition for "Something.What ever".
Hope that makes sense!
Derrick "Joe" <jb*******@noem ail.noemail> wrote in message news:eq******** ******@TK2MSFTN GP10.phx.gbl... It compiles fine but I get a warning about enum whatever being defined in 2 locations.
"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message news:%2******** **********@TK2M SFTNGP12.phx.gb l... That looks perfectly fine, it shoudl compile ok
Ollie "Joe" <jb*******@noem ail.noemail> wrote in message news:e%******** ********@TK2MSF TNGP14.phx.gbl. .. // In linked .cs namespace something { public enum whatever {abc, def,}; }
// project A public class ProjectA { public something.whate ver GetEnum() { return something.whate ver.abc; } }
// project B private void CallProjectACla ss() { ProjectA a = new ProjectA(); a.GetEnum(); }
"Ollie Riches" <ol**********@p honeanalyser.ne t> wrote in message news:ew******** ******@TK2MSFTN GP15.phx.gbl... > So how exactly is the enum defined and are you trying to use it across > different projects and\or namespaces? > > HTH > > Ollie Riches > > "Joe" <jb*******@noem ail.noemail> wrote in message > news:Oj******** ******@TK2MSFTN GP14.phx.gbl... >>I have a .cs file which is linked to several other projects. All my >>classes in this file are defined as internal. I would like to have an >>enum defined as well in the namespace but I get an error from one >>project that the accessibility of the enum is less (public) than that >>of a method which returns that's type. >> >> What is the best way to define this enum without getting duplicate >> define warnings or this error of less accessibility? >> >> Thanks, >> Joe >> > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Glenn Venzke |
last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an
enum. Is it possible to pass the item name without the enum name in your
calling statement?
EXAMPLE:
public enum EnumName
FirstValue = 1
SecondValue = 2
ThirdValue = 3
|
by: Andreas Huber |
last post by:
Hi there
Spending half an hour searching through the archive I haven't found a
rationale for the following behavior.
using System;
// note the missing Flags attribute
enum Color
{
|
by: zheng |
last post by:
I create a OCX program with ATL project, and One parameter in the interface
function is ENUM type, and I has defined the ENUM type in the interface, but
compiled falid with MIDL2001, in the generated IDL file, I find the
generated result is not the same with my think, and What can I do?
The generated IDL is so:
in the interface define file(header file):
_interface IMyInterface:...
{
typedef enum _STATE
|
by: MikeS |
last post by:
Hi,
I'm running into a very annoying issue when trying to use an enum defined in a C header file within a Managed C++ application.
Within the 'C' header file, there is an enum defined as
typedef enum _tagLiffeSystemMode
{
LIFFE_SYSTEM_MODE_UNDEFINED = LIFFE_CONSTANT_RANGE__SYSTEM_MODE
,LIFFE_SESSION_START
|
by: Steven Nagy |
last post by:
So I was needing some extra power from my enums and implemented the
typesafe enum pattern.
And it got me to thinking... why should I EVER use standard enums?
There's now a nice little code snippet that I wrote today that gives me
an instant implementation of the pattern. I could easily just always
use such an implementation instead of a standard enum, so I wanted to
know what you experts all thought.
Is there a case for standard enums?
| |
by: Jens Müller |
last post by:
I have a file here with several enums:
#ifndef PLANARSEP_OPTIMIZE_H
#define PLANARSEP_OPTIMIZE_H
enum fund_cycle_behavior_t
{PASS_MODE_FIRST,
PASS_MODE_BEST,
PASS_MODE_ALL};
|
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
};
|
by: Charlie |
last post by:
I tried to post this before and I apologize if I am repeating myself,
but I do not see the post anywhere.
But anyway,
I have a file, data.c, where I define all of my global variables. I
then use the extern keyword to reference those variables from a header
file, data.h, which I include in every file.
I am defining an enum type and variable in data.c:
|
by: Charlie |
last post by:
I have a file, data.c, where I define all of my global variables.
I then have a header file, data.h, which I include in every file in
which I reference all of the variables defined in data.c.
For the most part, I am having no problem with this. However, I
defined an variable of type myenum in data.c:
enum myenum
{
|
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...
|
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,...
| |
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |