Skip to main content

Microsoft Silverlight

Answered Question Crazy error in the business objectRSS Feed

(0)

Aashish Gupta
Aashish ...

Member

Member

30 points

58 Posts

Crazy error in the business object

Hi all, 

I am using Silverlight 3 and silverlight toolkit July release 

There are two System.ComponentModel.DataAnnotation files on my system one inside 

c:/Program Files/Reference Assemblies/Microsoft/Framework/v3.5/System.ComponentModel.DataAnnotations

 And another one is inside c:/Program files/ Microsoft SDK's/ Silverlight/V3/Library/Client/System.ComponentModel.DataAnnotations

 Now my business objects look like

 

 [DataMember]
        [Key()]
        public int? PersonId
        {
            get
            {
                return _personId;
            }
            set
            {
                if (_personId != value)
                {
                    var context = new ValidationContext(this, null, null);
                    context.MemberName = "PersonId";
                    Validator.ValidateProperty(value, context);
                    _personId = value;
                    OnPropertyChanged("PersonId");
                }
            }
        }

Everything was working fine until yesterday this crazy error aroused of nowhere it's breaking at the line 

Validator.ValidateProperty(value,context); and is generating the below mentioned error

Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.

Source System.ComponentModel.DataAnnotations

 Steps which i already took are

1.Reinstalled the silverlight_tools for VS2008SP1

2.Reinstalled the silverlight toolkit though it has nothing to do with the toolkit

 

 Also one more important thing the assembly installed in my GAC is from Reference Assemblies path which i mentioned above and not from the silverlight path

and its public key token is 31bf3856ad364e35

and its file version is 3.5.30729.1

I have installed the silverlight one also using gacutil but the added assembly has  public key token as ddd0da4d3e678217

and its not equal to what the error says so what's the solution i have nothing to do with the code that i know 

its some crap assembly referencing problem i don't know why microsoft gives two assemblies with same things it horrible.

Anyways any help is appreciated so that i can progress in my project.

 

 

www.smallworkarounds.net

MarkMonster
MarkMonster

Contributor

Contributor

5220 points

1,046 Posts

Re: Crazy error in the business object

Is this Business Object living on the Server side or on the Silverlight side? Because if it's living in the Server side, you should reference the other System.ComponentModel.DataAnnotations.

It tries to find the System.Core for Silverlight.

Mark Monster - MCPD Enterprise
http://mark.mymonster.nl
Silverlight and Expression Insiders UG

Dont forget to click "Mark as Answer" on the post that helped you.

Aashish Gupta
Aashish ...

Member

Member

30 points

58 Posts

Re: Re: Crazy error in the business object

 Hi Mark

Thanks for the quick reply

What happens in my solution is it uses EntityFramework so i have a dataAccess project which contains my edmx

There are two service projects which are hosted on other servers and they are not hosted inside iis they use this Web.BO project which is generating errors.

Instead of using the WCF generated service types in the Silverlight apps what we are doing is using the web.bo object files as a link in another project which is of type silverlight and having the same structure but no physical files only the linked files from the actual web.bo project

This is done because we can't reference a dll project inside Silverlight and we don't want to use types generated by the service.

So from silverlight we send and recieve the same objects because just the name and project is different in Silverlight and other places rest things remain same so to reuse code we are doing this 

I think we were using the same dll found inside the Silverlight everywhere but the strange thing is that everything used to work fine till just yesterday and what has happened in one day is a big question

Can u suggest something

 

www.smallworkarounds.net

Aashish Gupta
Aashish ...

Member

Member

30 points

58 Posts

Re: Re: Re: Crazy error in the business object

 The difficulty in using the Server side dll is that when i reference the server side dll it does not recognize the key attribute

Error    1    The type or namespace name 'KeyAttribute' could not be found (are you missing a using directive or an assembly reference?)    E:\Projects\TestEdmx\TestEdmx\ccSkiJump.Web.BO\BO\County.cs    14    10    ccSkiJump.Web.BO

Also that assembly does not have ValidationContext, displayName attribute and many other things 

www.smallworkarounds.net

Aashish Gupta
Aashish ...

Member

Member

30 points

58 Posts

Answered Question

Re: Re: Re: Re: Crazy error in the business object

 Ok Thanks all

I finally solved my problem.

Somehow the reference to the System.ComponentModel.DataAnnotations was removed from the client i.e the silverlight app and this was causing trouble although going by compilation errors i don't need that assembly on my client but logically thinking i think it should be included because you will be using this to validate on forms and various other things on the client so it should be downloaded with the xap although it won't give any compile time error but it will fail at runtime

So this was the error although a little tricky to find in such a big application hope it helps other's who get the same problem.

 

www.smallworkarounds.net
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities