Preventing namespaces being shared through class libraries

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

Hi all,

Just wondering if anyone has a solution to this problem.

I've created a class library which encapsulates some logon code.
This library uses one of my registry classes as well as some ODBC
database access queries, so the top of the main code looks like this:

using System;
using System.Data.Odbc;
using RegistryAccess;

(Where RegistryAccess is my registry access namespace)

The problem arises when I add this class library to another solution,
it seems to share RegistryAccess with the parent solution, conflicting
with locally-included copies, producing compiler warnings like this:

c:\newcvs\server software\logon server\commondata.cs(97,17): warning
CS1595: 'RegistryAccess.clsRegistry' is defined in multiple places;
using definition from 'C:\newcvs\Common\clsRegistry.cs'

This is acceptable, since the compiler has chosen the correct one, but
I would still prefer that the namespace is kept out of the public view
of the class library.

Any ideas?

Cheers,

Alex.
Remove ernie and bert from email address to reply.
 
Alex said:
Just wondering if anyone has a solution to this problem.

I've created a class library which encapsulates some logon code.
This library uses one of my registry classes as well as some ODBC
database access queries, so the top of the main code looks like this:

using System;
using System.Data.Odbc;
using RegistryAccess;

(Where RegistryAccess is my registry access namespace)

The problem arises when I add this class library to another solution,
it seems to share RegistryAccess with the parent solution, conflicting
with locally-included copies, producing compiler warnings like this:

c:\newcvs\server software\logon server\commondata.cs(97,17): warning
CS1595: 'RegistryAccess.clsRegistry' is defined in multiple places;
using definition from 'C:\newcvs\Common\clsRegistry.cs'

That's not a problem of sharing *namespaces* - it's a problem of
sharing *classes*. You shouldn't have a class visible in more than one
project. It sounds to me like you're including the class library *and*
one of the classes in the project.

If you can come up with a small solution which demonstrates the
problem, feel free to email it to me and I'll be able to comment
further.
 
Declaring all but one clsRegistry class as "internal" would
fix the problem. By doing that you're keeping the visibility
of a class to the internal assemblies only.

namespace RegistryAccess{
internal class clsRegistry{
//...
 
Back
Top