donderdag 6 november 2008

Unity and MethodAccessException

This was such a day where I got a problem on my desk even before I got coffee. By now, problem is solved and I had some coffee, so time to register the problem and the solution here.

I'm working on a software package for a customer. Up to the previous version we used the ObjectBuilder dependency injection framework. With the latest release we converted it to Unity. Everything still worked in local tests.

So, it was deployed at two client test-sites. Neither of them worked. The log was full of MethodAccessExceptions. This resulted in Unity not being able to resolve many dependencies. We tried:
- moving all the dll's to the same directory as the exe;
- updating to Unity 1.2 (we started with 1.0);
- signing the Unity dll's (see here for an explanation);
- updating the test server (Windows 2003 Server) with Microsoft Update.

It turned out that there were 44 updates available for the server, including Windows Server 2003 SP1. Finally, after installing these updates, it worked. We think SP1 was the necessary one. However, since all this updating is done through a remote desktop we didn't bother trying to find out which of the updates actually did the trick.

Along the way, with signing the Unity dll's, I found out that I cannot open the Unity solution file. Neither the 1.0 nor the 1.2 version. It states that "The projectfile [...]\Tests.ObjectBuilder.csproj cannot be opened. The project type is not supported by this installation.So far, I have not found out what is required to open this project file. If anyone knows, please post a reply.

Second thing along the way: Dependency injection is nice, but you can hardly find out which type is loaded when. If you want some insight in this, you can use the Fusion Log viewer, Fuslogvw.exe in the Windows SDK (on my machine: C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin). Susanne Cook has blogged about it here.

Back to normal work....

Geen opmerkingen: