Fredrik Forssen - 69 - Aug 22, 2014

Im using servicestack.client in a WPF project and in this project I am using DesignInstance to bind to a sample viewmodel in the designer in order to get data to work with in the design view.
My viewmodels generally references an instance of JsonServiceClient in order to be able to load data from the server.
In 4.0.24 this worked perfectly, I’d set the jsonserviceclient to null in the sample viewmodels and pass in a real one through dependency injection in the real viewmodels. However after upgrading to 4.0.30 this is no longer the case. When creating the design time sample viewmodel I get an error that looks like this:

"Method ‘GetAsync’ in type ‘ServiceStack.JsonServiceClient’ from assemby ‘ServiceStack.Client, Version=, Culture=neutral, PublicKeyToken=null’ does not have an implementation"

Reverting to 4.0.24 solves the problem. I have checked my references, and I am not referencing any servicestack dll’s by a specific version and all references points to the correct files with the correct versions. I have also checked my GAC and there is nothing servicestacky in my GAC :confused:

Does anyone know anything about this?

Fredrik Forssen:

I have recreated the problem in a tiny new project, which can be downloaded here:

Fredrik Forssen:

I also noticed when I upgraded my references from 4.0.24 to 4.0.30 that my project began complaining about not having a reference to System.Runtime.Serialization. Has this dependency been added between those versions?

I’ve downloaded the app, but I’m not sure what I’m looking for as the app runs fine? I just see a blank window where I can drag buttons and text boxes, etc. and runs without issue, i.e. I’m not seeing any errors?

Have you looked at the latest release notes? i.e. the breaking change was SS.Interfaces was converted to a pure PCL dll:
One of the issues is that if you might run into is needing to explicitly reference System.Net. As for System.Runtime.Serialization that’s always been a dependency, but like System.Net it may need to have an explicit reference now, but I haven’t needed to or have seen this error.

Fredrik Forssen:

Ah. Alright. The window contains a single label which should show the text “Monkey sample” in design mode and the text “Monkey” when you actually run the program. The errors are a bit hard to see since you can only see them in the XAML editor in mainwindow.xaml (I’m using ReSharper, unsure if actually seeing this error is a resharper feature or if it’s in vanilla VS)

If you have a look in the TestViewModel.cs file you have one set of two viewmodels (and two commented out). If you first uncomment the ones with the comment that says that “these works” and then clean and rebuild the solution (the xaml designer is a bit finnicky…) and then open MainWindow.xaml you should see that you can see the sample data “Monkey sample” in the window in design mode. (Not when you’re running the program!)

If you then go back to the set of classes marked as “not working” and then clean and rebuild and open mainwindow.xaml again then you’ll see that there’s no “Monkey sample” in the design mode.

The difference between the classes is as you can see only the property ServiceClient and the setting of that one property.

ok I see the designer error now, but I’ve no idea what’s causing it. It’s a TypeLoadException which a lot of people seem to run into with the WPF Designer - but I’m not seeing why, since GetAsync does indeed have an implementation. 

Anyway one solution I found is to use IServiceClient instead of the concrete JsonServiceClient, which is actually recommended since it has less coupling and it’s easier to mock

Fredrik Forssen:

Ah, yea using IServiceClient might be a good alternative and a quick solution to the problem.
Still, it’s kind of strange that it showed up between 4.0.24 and 4.0.30. No ideas as to what changes may have triggered it?

Well the big change in v4.0.30 (please see the release notes), was converting SS.Interfaces into a pure PCL dll so I’m guessing that’s somehow causing it. Also the SS.Client PCL dlls have been merged into the same SS.Client Nuget Package, but your project is doesn’t reference the PCL Client versions so I doubt that would have any effect.

paolo ponzano:

same problem of Fredrick on xp machine…runs fine on 7