-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version Mismatch #44
Comments
hi. not that i am aware of. due you have the stack trace? i will try to analyse. |
@esskar Here's an exemplar stack trace. The one client application is compiled, for example, with version 1.2.3.0 of the DTO assembly. The server, on the other hand is compiled with version 1.2.4.0 of the same. The DTO assembly is signed, but not sure if it makes any difference.
|
Seems like this is what @esskar exactly tried to avoid, i.e. picking wrong types with the same names. I mean how can we assure without a complex introspection that your DTO lib actually contains compatible types? |
@vsoldatkin @esskar Using the sample code provided as part of Serialize.Linq for discussion, I think the answer to my question lies in how But after studying this some more, I realized that the ultimate issue I am trying to solve is this: What if the client application had no knowledge nor access to I solved it by modifying the custom expression context subclass, like so: public override Type ResolveType(TypeNode node)
{
var type = base.ResolveType(node);
if (type == typeof(PersonDto))
return typeof(Person);
if (type == null)
{
// Look at node.Name and make a guess based on string matching which class
// to map to, and ...
return thatType;
}
return type;
} I figure this is no worse than the original version, which is hard-coding a mapping based on some knowledge about the classes. I have implemented this and it is working for me. |
@bitaxis thanks for that! idea: when the type to serialize is from an anonymous class, we use the full qualified name, otherwise we stick to type.Fullname how does that sound? |
@esskar I think the way it is now is fine. What I ended up doing is implement two dictionaries I pre-populate. One is Now, you could maybe clarify the purpose of |
Personally I don't like the idea of FullName based type guessing in any form. I'm pretty sure I'll be able to forge a test case to break it. I would rather stick to the safe FQN-based implementation and provide an extension point for a user to implement his own unsafe ExpressionContext (specifically his own ResolveType implementation).
The only safe way is to share a DTO assembly. Otherwise it falls into a broader problem: What if I want to swap actual types for another types according to some rules, taking responsibility for all the risks? And the answer is: Then implement your own ResolveType. |
Is there a way to relax or for me to override version checking behavior on the DTO assembly when de-serializing? I have a client that uses a slightly different version of the DTO than the server. They are completely compatible, but when
Serialize.Linq
is being invoked on the server-side, it complains about not being able to find the DTO assembly due to version number difference.Thanks for this library. It is making my job easier and more fun.
The text was updated successfully, but these errors were encountered: