The type conflicts with the imported type

  • Thread starter Thread starter David Jackson
  • Start date Start date
D

David Jackson

Hello,

My company has a collection of reusable base classes for common functions
like encryption and mail which can be dropped into any Visual Studio
project. Several of these are currently being used on the corporate
intranet.

I have now been asked to create a class library which will contain some
SharePoint functionality. However, this class library also needs to use some
of the reusable base classes.

When I add the class library to the intranet project, set a reference to it
and rebuild, I see lots of warnings like this:

Warning 1 The type 'BaseClasses.CEncryption' in
'C:\Users\David.Jackson\Documents\Visual Studio
2008\Projects\intranet\intranet\code\BaseClasses\Encryption.cs' conflicts
with the imported type 'BaseClasses.CEncryption' in
'C:\Users\David.Jackson\Documents\Visual Studio
2008\Projects\intranet\SharePoint\bin\Debug\SharePoint.CMS.dll'. Using the
type defined in 'C:\Users\David.Jackson\Documents\Visual Studio
2008\Projects\intranet\intranet\code\BaseClasses\Encryption.cs'.
C:\Users\David.Jackson\Documents\Visual Studio
2008\Projects\intranet\intranet\Global.asax.cs 36 42 intranet

I tried removing the using directive in the class library and referring to
the base classes explicitly, but that didn't make any difference.

I also tried a using directive alias in the class library e.g.

using CLBaseClasses = BaseClasses;

but that also didn't make any difference.

I can't change the namespace of the reusable base classes because they are
shared in SourceSafe.

I understand that the above is merely a warning and not a true error, and
everything seems to work correctly, so can I just ignore it? I would prefer
to find a way of eliminating these warnings if possible.

Thank you.

DJ
 
Hello,

My company has a collection of reusable base classes for common functions
like encryption and mail which can be dropped into any Visual Studio
project. Several of these are currently being used on the corporate
intranet.

I have now been asked to create a class library which will contain some
SharePoint functionality. However, this class library also needs to use some
of the reusable base classes.

When I add the class library to the intranet project, set a reference to it
and rebuild, I see lots of warnings like this:

Warning 1 The type 'BaseClasses.CEncryption' in
'C:\Users\David.Jackson\Documents\Visual Studio
2008\Projects\intranet\intranet\code\BaseClasses\Encryption.cs' conflicts
with the imported type 'BaseClasses.CEncryption' in
'C:\Users\David.Jackson\Documents\Visual Studio
2008\Projects\intranet\SharePoint\bin\Debug\SharePoint.CMS.dll'. Using the
type defined in 'C:\Users\David.Jackson\Documents\Visual Studio
2008\Projects\intranet\intranet\code\BaseClasses\Encryption.cs'.
C:\Users\David.Jackson\Documents\Visual Studio
2008\Projects\intranet\intranet\Global.asax.cs 36 42 intranet

I tried removing the using directive in the class library and referring to
the base classes explicitly, but that didn't make any difference.

I also tried a using directive alias in the class library e.g.

using CLBaseClasses = BaseClasses;

but that also didn't make any difference.

I can't change the namespace of the reusable base classes because they are
shared in SourceSafe.

I understand that the above is merely a warning and not a true error, and
everything seems to work correctly, so can I just ignore it? I would prefer
to find a way of eliminating these warnings if possible.

Thank you.

DJ

You still have a reference to the other library, which contains the
same classes in the same namespaces. Choices:

1. Get rid of the old references
2. Change the namespaces when importing the classes into the new
library

Peace and Grace,

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
 
Hi Gregory,

Thank you for replying.
You still have a reference to the other library, which contains the
same classes in the same namespaces. Choices:

Yes, that's correct.
1. Get rid of the old references

How can I do that? The intranet project needs the Encryption base class and
the SharePoint class library needs the Encryption base class.
2. Change the namespaces when importing the classes into the new
library

As I mentioned, the classes are shared in SourceSafe. If I change the
namespaces in one place, all of the other instances of the base classes will
also change.

For further clarification, the structure of the solution is like this:

<intranet solution>
<intranet project>
<BaseClasses>
<Encryption> *
<SharePoint class library project>
<BaseClasses>
<Encryption> *

* the same base class shared in SourceSafe.

Thank you,

DJ
 
Hi Gregory,

Thank you for replying.


Yes, that's correct.


How can I do that? The intranet project needs the Encryption base class and
the SharePoint class library needs the Encryption base class.


If you have a reference chain, then you cannot do this option. Best to
go to option 2.
As I mentioned, the classes are shared in SourceSafe. If I change the
namespaces in one place, all of the other instances of the base classes will
also change.

You will have to branch SourceSafe and move the classes, or move the
one's shared between the two libaries to their own separate library
and reference from both.

You cannot have the same class in the same namespace in two projects
if both are going to be used by a third project. You have to refactor
them out into a single framework type of library and call from the
other two libraries.

It sounds to me like you, at minimum, have some base classes that need
to go into a framework library that is used by both the Sharepoint
andthe intranet project(s).

Peace and Grace,

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
 
It sounds to me like you, at minimum, have some base classes that need
to go into a framework library that is used by both the Sharepoint
and the intranet project(s).

That fixed it! Thank you.

DJ
 
Back
Top