C# syntax issue

K

Ken Allen

OK, this one has me completely at a loss. Please note that the capitalized
names in the following are for reference only and do not reflect the casing
used for the actual namespaces or types.

I have one assembly that is common to the client and server component, let
us call it COMMON. This is the name of the namespace as well. Inside this
namespace I have defined a public enum named MY_ENUM.

Inside this same assembly I defined another namespace that can be used by
both client and server components, called COMMON.WIN32 -- as the name
implies, this namespace contains some basic WIN32 interface stuff that can
be called from both client and server code.

For the server components I have another assembly that defines another
namespace, COMMON.WIN32.SERVER, that contains some more WIN32 API stuff and
wrappers that are only used in server-side components.

Now, the problem is that the client code contains a "using COMMON" and is
able to access MY_ENUM.ENTRY1 without problem, bu the code in the server
assembly (inside a COMMON.WIN32.SERVER class) generates an error on a
reference to MY_ENUM.ENTRY1 indicating that I may be missing a namespace
reference -- that file also contains a "using COMMON" as well as a "USING
COMMON.WIN32" statement.

Strangely enough, the MY_ENUM entry also does not appear in intellisense
when typing.

Does anyone have any idea why I cannot use the enumeration from the COMMON
namespace when writing code for a deeper namespace? I saw nothing that
indicated why this should be wrong.

-Ken
 
B

Bruno Jouhier [MVP]

Is this a "compiler" issue or only an "intellisense" issue? There are cases
where Intellisense does not give you something but the compiler accepts it.
So, first thing to do is to try typing it and see if the code compiles
(maybe it will).

Also, if you are working with several projects/assemblies, Intellisense will
pick up you last changes in the current project but it won't pick them up in
other projects that reference this assembly, you have to compile the
assembly that contains your latest changes to get them in your other
project's Intellisense. The end result is not always as fluid as you would
like it to be.

Bruno.
 
K

Ken Allen

Bruno Jouhier said:
Is this a "compiler" issue or only an "intellisense" issue? There are cases
where Intellisense does not give you something but the compiler accepts it.
So, first thing to do is to try typing it and see if the code compiles
(maybe it will).
No, this is both. Intellisense is not showing it and the compiler refuses to
compile my code!
Also, if you are working with several projects/assemblies, Intellisense will
pick up you last changes in the current project but it won't pick them up in
other projects that reference this assembly, you have to compile the
assembly that contains your latest changes to get them in your other
project's Intellisense. The end result is not always as fluid as you would
like it to be.
I am recompiling all assemblies together, so this should not be the problem.

-Ken
 
J

Jon Skeet [C# MVP]

Ken Allen said:
OK, this one has me completely at a loss. Please note that the capitalized
names in the following are for reference only and do not reflect the casing
used for the actual namespaces or types.

I have one assembly that is common to the client and server component, let
us call it COMMON. This is the name of the namespace as well. Inside this
namespace I have defined a public enum named MY_ENUM.

Inside this same assembly I defined another namespace that can be used by
both client and server components, called COMMON.WIN32 -- as the name
implies, this namespace contains some basic WIN32 interface stuff that can
be called from both client and server code.

For the server components I have another assembly that defines another
namespace, COMMON.WIN32.SERVER, that contains some more WIN32 API stuff and
wrappers that are only used in server-side components.

Do you definitely have a reference from this third assembly to the
COMMON one? Not a using statement, but a reference?
 
K

Ken Allen

I am not quite certain how I fixed it, but the problem has disappeared! I
removed the reference to the lower level assembly and added it again and the
problem stopped! Odd.

-Ken
 

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