Friday, August 27, 2010

MSTest "System.ArgumentException: [class.method] The member specified could not be found"

Came across this error writing unit tests using MSTest in Visual Studio 2008. The source of the problem was I had two versions of the same dll in the GAC. Removing the older version fixed the problem. The reason why I was only seeing this error during runtime and not during compilation is the test project referenced the assembly it was testing in the bin directory of the project which is why the build succeeded. However, during runtime the tests referenced the assembly in the GAC before the assembly in the bin of the project which is expected.

Monday, June 14, 2010

Access Denied using SetPersonalizationDirty

Just recently I ran across a test case I was testing on a web part in SharePoint. I was opening the page with a user that had read only access to the page and I was getting an "Access Denied" message. After several hours of hunting I discovered that it was related to calling SetPersonalizationDirty() for the current web part. Obviously a user with read only access shouldn't be allowed to update the web parts properties. So here's what I used to resolve the issue:


Tuesday, January 19, 2010

How to Resize a Fixed VHD

I just set up a bootable virtual machine in Windows 7 running Windows Server 2008 R2. I realized after creating the VM that I didn't need as much capacity as I allocated for the VHD file. After several hours of failed attempts I finally came up with a solution and wanted to share.

1) I first attached the VHD using Disk Management in Windows 7.
2) Using DiskPart I shrank the VHD volume down to a manageable size running the following commands. Note I had 100 GB of free space.
-select disk 1 (varies depending on the number assigned to the attached VHD)
-select volume 0 (also varies depending on the number assigned to the VHD volume in the disk)
-shrink ( If you would not like to shrink the volume to the absolute minimum capacity I would recommend using the [desired=] [minimum=] parameters. I repeated this command until I shrank the volume to the desired size. You can use detail disk command to check the actual amount of space needed for the disk).
3) After shrinking the VHD volume down you'll notice in Disk Management that there is a certain amount of unallocated space in the VHD. To remove that unallocated space use VHDResizer to actually resize the VHD to the size of the volume you just shrank.