OT: Error while compiling library

OT: Error while compiling library

Old forum URL: forums.lhotka.net/forums/t/2010.aspx


albruan posted on Wednesday, December 20, 2006

While trying to build a library for a new project, I get the following error: "The type 'Library.User' must be convertible to 'Library.ICloneableIdentity' in order to use it

as parameter 'T' in the generic type or method 'Library.ProjectBusinessBase<T>'."

 

Here’s the line where the error occurs:

 

   [Serializable()]

   public partial class User : Library.ProjectBusinessBase<User>

 

I have ProjectBusinessBase declared as follows:

 

   [Serializable()]

   public abstract class ProjectBusinessBase<T> : Csla.BusinessBase<T> where T : ProjectBusinessBase<T>, ICloneableIdentity

 

ICloneableIdentity is defined as:

 

   public interface ICloneableIdentity

   {

      bool CanCloneIdentity { get; }

      object CloneNewIdentity(object parentKey);

   }

 

What do I need to do in order to successfully compile my library?

xal replied on Wednesday, December 20, 2006

According to the base class' definition (ProjectBusinessBase<T>), every class that inherits from it must implement ICloneableIdentity...

So, in order to make this compile, you need to implement that interface in the deriving class (User).
If that's not what you want perhaps you want to implement that interface in your base class, in which case, the definition would change to:

public abstract class ProjectBusinessBase<T> : Csla.BusinessBase<T>, ICloneableIdentity
where T : ProjectBusinessBase<T>


Andrés

albruan replied on Thursday, December 21, 2006

Thanks Andrés!  I kept thinking my declaration for the abstract class didn't quite look correct.

Copyright (c) Marimer LLC