Skip to content
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

Outdated code from 08/2012 post #7

Open
fagnercarvalho opened this issue May 2, 2015 · 5 comments
Open

Outdated code from 08/2012 post #7

fagnercarvalho opened this issue May 2, 2015 · 5 comments

Comments

@fagnercarvalho
Copy link

The following post is outdated according to the newer NancyFX version (1.2.0.0).
I was getting a compilation error in the JsonNetSerializer because a Extensions property was missing and after that I get a runtime exception:

An unhandled exception of type 'System.ArgumentException' occurred in Nancy.dll

Additional information: types: The same implementation type cannot be specified multiple times for Nancy.ISerializer

TestProject.JsonNetSerializer

To solve that I change the bootstrapper code to that:

        protected override NancyInternalConfiguration InternalConfiguration
        {
            get
            {
                return NancyInternalConfiguration.WithOverrides(
                    c =>
                        {
                            c.Serializers.Remove(c.Serializers.FirstOrDefault());
                            c.Serializers.Insert(0, typeof(JsonNetSerializer));
                        });
            }
        }

I dont know if this is the best approach right now but its working here.

What you think?

@alexbeletsky
Copy link
Owner

@fagnercarvalho sure, the article is very old. As far as I remember, I was playing with NancyFX 0.0.9 (or something) that time..

Nancy is well known for friendliest community ever, so do not hesitate and ping those guys :)

/cc @jchannon

@jchannon
Copy link

jchannon commented May 3, 2015

You shouldn't need to do that, should just install Nancy.Serializers.JsonNet and Nancy will pick that serializer up and use that. 😄

@oscarsan
Copy link

I think this is still valid, you may want to use some serializer which is not JsonNet. In my case, i really dont understand why nancy has its own version of the same serializer inside System.Web.Script.Serialization. Should default serializer in nancy use rather this class than its own implementation of the same.

@jchannon
Copy link

Nancy has no dependency on System.Web and doesn't have that serializer you mention as its default. It uses one from the mono team and then amended where needs be.

@oscarsan
Copy link

Ok, all the classes just look exactly the same. But some methods are missing in the default one. My problem is that I had already implemented all the converters for special classes and those converters will not work with the default serializer. In any case the code above work for replacing the serializer with any other one, not necessarily Json.Net.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants