Home All Groups Group Topic Archive Search About

Is this CLS compliant?

Author
16 Apr 2007 10:38 PM
Andrew
Hello, friends,

I defined a C# class like the follows in .net 2.0:

    [Serializable]
    public class ContractInfo
    {
        private string number;
        private string transCode;
        private int? vcCode;
        private DateTime? termFrom;
        private DateTime? termTo;
        private decimal? revMax;
        private DataTable dtAttribute;

        public ContractInfo()
        {
        }

        public string Number {set {this.number = value;}get {return
this.number;}}
        public string TransCode {set {this.transCode = value;}get {return
this.transCode;}}
        public int? VCCode {set {this.vcCode = value;}get {return
this.vcCode;}}
        public DateTime? TermFrom {set {this.termFrom = value;}get {return
this.termFrom;}}       
        public DateTime? TermTo {set {this.termTo = value;}get {return
this.termTo;}}
        public decimal? RevMax {set {this.revMax = value;}get {return
this.revMax;}}
        public DataTable DTAttribute { set { this.dtAttribute =
value.Copy(); } get { return this.dtAttribute; } }
    }

and I called a Window Form function, in which a ContractInfo data type
parameter was passed as the follows:

     public void PopulateContractInfo(ContractInfo contractInfo)
     {
         ..........
     }

When our build machine compiled, it complained, saying: Argument type
'Contract.ContractInfo' is not CLS-compliant. (CS3001)

I checked our code, I saw that we did have [assembly: CLSCompliant(true)] in
AssemblyInfo.cs.

So, I was confused.

Any ideas, reference papers? How to fix it? Thanks a lot.

Author
17 Apr 2007 3:08 AM
RobinS
I suspect it's the DataTable that's getting you. Try taking it out and see
if it compiles.

Robin S.
------------------------------------------
Show quote
"Andrew" <And***@discussions.microsoft.com> wrote in message
news:2B7E3616-CD00-486F-B571-82BAEC6F8288@microsoft.com...
> Hello, friends,
>
> I defined a C# class like the follows in .net 2.0:
>
>    [Serializable]
>    public class ContractInfo
>    {
>        private string number;
>        private string transCode;
>        private int? vcCode;
>        private DateTime? termFrom;
>        private DateTime? termTo;
>        private decimal? revMax;
>        private DataTable dtAttribute;
>
>        public ContractInfo()
>        {
>        }
>
>        public string Number {set {this.number = value;}get {return
> this.number;}}
>        public string TransCode {set {this.transCode = value;}get {return
> this.transCode;}}
>        public int? VCCode {set {this.vcCode = value;}get {return
> this.vcCode;}}
>        public DateTime? TermFrom {set {this.termFrom = value;}get {return
> this.termFrom;}}
>        public DateTime? TermTo {set {this.termTo = value;}get {return
> this.termTo;}}
>        public decimal? RevMax {set {this.revMax = value;}get {return
> this.revMax;}}
>        public DataTable DTAttribute { set { this.dtAttribute =
> value.Copy(); } get { return this.dtAttribute; } }
>    }
>
> and I called a Window Form function, in which a ContractInfo data type
> parameter was passed as the follows:
>
>     public void PopulateContractInfo(ContractInfo contractInfo)
>     {
>         ..........
>     }
>
> When our build machine compiled, it complained, saying: Argument type
> 'Contract.ContractInfo' is not CLS-compliant. (CS3001)
>
> I checked our code, I saw that we did have [assembly: CLSCompliant(true)]
> in
> AssemblyInfo.cs.
>
> So, I was confused.
>
> Any ideas, reference papers? How to fix it? Thanks a lot.
>
>
>
>

AddThis Social Bookmark Button