New Posts New Posts RSS Feed: 'System.Reflection.RuntimeMethodInfo' cannot be serialized
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

'System.Reflection.RuntimeMethodInfo' cannot be serialized

 Post Reply Post Reply
Author
ahopper View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Mar-2010
Location: Atlanta, GA
Posts: 8
Post Options Post Options   Quote ahopper Quote  Post ReplyReply Direct Link To This Post Topic: 'System.Reflection.RuntimeMethodInfo' cannot be serialized
    Posted: 19-Mar-2010 at 1:22pm

Aha! We found it. Our client-side app.config did not have the clientApplicationType attribute set to “Silverlight” and this appears to break the code that serializes the Where clause.

Back to Top
ahopper View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Mar-2010
Location: Atlanta, GA
Posts: 8
Post Options Post Options   Quote ahopper Quote  Post ReplyReply Direct Link To This Post Posted: 18-Mar-2010 at 3:29pm
Hi, Ting! Yes, these are EF classes, and DisplayName is bound to a database field. To what address should I send the edmx file?
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 18-Mar-2010 at 12:53pm
Hi Andy,
 
A)  If Principal is a POCO class you should do these things:
  1. Mark the class with the [DiscoverableType(DiscoverableTypeMode.KnownType)] attribute or have the class implement IKnownType (a marker interface).
  2. Mark each property with the [DataMember] attribute.
For example:
    [DiscoverableType(DiscoverableTypeMode.KnownType)]
    public class Principal {
    ...
      [DataMember]
      public String DisplayName {
        get { ... }
        set { ... }
      }
    ...
    }
 
B)  If Principal is a standard DevForce Entity, you can only issue queries to the database on properties that are backed by database columns.  If DisplayName is a calculated or custom property, the database engine doesn't know what to do with it.  Once you have brought down the object into the client-side cache, however, you can use LINQ-to-objects to query on any arbitrary property.
 
If you're still having problems, send us the edmx file and we'll have a look.
Good luck!
 
 
Back to Top
ahopper View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Mar-2010
Location: Atlanta, GA
Posts: 8
Post Options Post Options   Quote ahopper Quote  Post ReplyReply Direct Link To This Post Posted: 18-Mar-2010 at 9:22am
We are trying to use the fluent interface to generate a Linq query that applies a where clause:
 
em.ExecuteQueryAsync<Principal>(em.Principals.Where(p => p.DisplayName == "ahopper"), this.QueryExecuted, null);
 
However, when the callback is invoked, it has an error:

“Type 'System.Reflection.RuntimeMethodInfo' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.”

 
Are we simply using the API incorrectly?
 
Many thanks!
Andy Hopper
Enterprise Architect, Wintellect
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down