3

A little bit of background: I recently recompiled the ServiceStack library from its source code (https://github.com/ServiceStack/ServiceStack). I also recompiled the ServiceStack.Text project, after completing some bug fixes. I copied the ServiceStack.Text dll file into the "lib" folder of the ServiceStack project (it is there because the ServiceStack solution does not include the serializers in Text).

Now I am getting TypeLoadExceptions, as follows:

System.TypeLoadException: Method 'get_StatusCode' in type 'ServiceStack.ServiceInterface.Testing.MockHttpResponse' from assembly 'ServiceStack.ServiceInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation. at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) at System.Reflection.RuntimeAssembly.GetExportedTypes() at ----my code from here...----

I'm not sure what the issue could be. I suspected it could be a circular DLL reference issue (DLL Hell) because ServiceStack.OrmLite is referenced (which also references back to other solutions in this project); however, after removing all references to ServiceStack projects, I still have not solved the problem.

This post seems to have some ideas, but I have not had any luck following through with those: TypeLoadException says 'no implementation', but it is implemented

Community
  • 1
  • 1
theMayer
  • 15,456
  • 7
  • 58
  • 90

1 Answers1

3

You're using dirty dlls for the different versions of ServiceStack's components which should all be kept in sync.

In the assembly of each major ServiceStack component dll is marked the version number, this matches up with the version that's deployed on NuGet, e.g. the latest version of ServiceStack is v3.9.38, you would want to ensure that you're using at least v3.9.38 of all the other libraries.

The core ServiceStack dependency matrix looks like:

ServiceStack.Text
  +
  > ServiceStack.Interfaces
  > ServiceStack.Common
      + 
      > ServiceStack.Redis
      > ServiceStack.OrmLite
          +
          > ServiceStack
              +
              > ServiceStack.ServiceInterface

If you're using v3.9.38 of ServiceStack.dll, you want to make sure that all sub components above ServiceStack is at least at v3.9.38.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • How do you prevent this problem when you build them? I don't want to have to build _every_ project and copy _every_ dll, I only want the ones I use... – theMayer Mar 14 '13 at 20:50
  • If you want to build from source you need to ensure the dependent components are properly propogated. If you clone the repos under `c:\src` you can use the build.bat scripts inside the `/build` folder of each major solution which automatically copies the release dlls to the right directories, e.g. in ServiceStack/lib. – mythz Mar 14 '13 at 20:59
  • This doesn't seem to solve the problem. I removed all the ServiceStack.OrmLite references (and dlls in the /lib folder), and rebuilt the solution by including the ServiceStack.Text project (so all references were being compiled in VisualStudio). I cleared all bin and obj folders using Git Cleanup. I also wiped out all Visual Studio caches. If there are dirty DLLs, I have no idea where they are coming from. – theMayer Mar 14 '13 at 23:01
  • Make sure you are building in **Release** mode for all projects (which should be the default). Other than that I don't know what to tell you, I develop like this every day. I just rebuild all the dependent projects first (starting from the top), run each of the build.bat scripts than RebuildAll of ServiceStack. – mythz Mar 14 '13 at 23:05
  • I'm just suspecting that it's not a bad DLL issue, that in fact something else is going on. I just don't know what it is. – theMayer Mar 14 '13 at 23:07
  • It's quite obvious that's what it is, one dll thinks MockHttpResponse has a **Status** property whilst the actual implementation that's being used doesn't. In this case it's your `ServiceStack.ServiceInterface.dll` that's old. – mythz Mar 14 '13 at 23:10
  • I've gotten to the point where the only projects that are being built are SS, SS.Text, SS.Common, SS.Interfaces, and SS.ServiceInterface. I just noticed that the projects were referencing a debug version of SS.Text, so I'll see if that fixes it. – theMayer Mar 14 '13 at 23:12
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/26203/discussion-between-rmayer06-and-mythz) – theMayer Mar 14 '13 at 23:16