I’ve been working on a small SharePoint project this week. I have a single machine setup - I’m developing in Visual Studio and deploying to a local installation of SharePoint
I set about writing the code, unit testing it and then deploying it into SharePoint. However when I came to re-run the unit tests (after deployment) I got the following error:
Exception: System.MissingMethodException: Method not found
This was slightly baffling exception. The method existed…I’d just added it.
After a couple of sanity checks; I realised the tests weren’t using the local version of my assembly. It was reading it from the GAC. The act of deploying the solution to SharePoint had installed the assembly on my behalf.
I uninstalled the assembly from the GAC via the VS command prompt using:
Gacutil /u “assemblyName”
This fixed the problem but causes a re-occurring issue every time I deploy to SharePoint.
A couple of options that may help around the re-occurring issue (Granted none of these are ideal) :
1. Add the assembly reference to the test project as a file reference rather than as a project reference. <Yuck>
2. Remove the assembly from the GAC as part of a pre-build event of the test project. This will work but clearly will make your deployed SharePoint solution screwy.
3. Increment the assembly version number in AssemblyInfo.cs after you deploy to SharePoint. <I could imagine this being frustrating for a team setup and someone checks the version number in by mistake.>
If anyone has a better workaround or a way to avoid the problem then let me know