Friday, December 28, 2007

MCTS: .NET Framework 2.0 Web Applications

Yesterday, I passed the 70-528 exam, so yes, I'm a Microsoft Certified Technology Specialist in .NET Framework 2.0 Web Applications now! What a mouthfull... I'm glad I got through it in one time, seeing how I had to study it during the holidays...

If you're taking the exam too and you want some general pointers: both custom controls and personalization were really important topics on my exam. However, don't focus on these two topics too much, since every exam can be completely different... But they did form a large part of my exam, so it won't hurt you to reread these topics an extra time.

Sunday, December 9, 2007

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

If you ever get the error "Attempted to read or write protected memory. This is often an indication that other memory is corrupt.", take a look at the rest of this post, it might save you a lot of time... I got it when writing a console application for SharePoint, but I think it might occur with other sorts of applications too.

I had been looking for a solution for many days and had seen lots of possible causes online, but none of them applied to my situation. Today, I noticed for the first time that Visual Studio gave me a warning when building. I hadn't noticed this before because there weren't any errors, so it just said "build succeeded", so I thought everything in my application was fine and it must have been something about the setup of the test server. Well, I clearly was wrong... Here's what the warning said:

Found conflicts between different versions of the same dependent assembly.

When double clicking this warning, Visual Studio asks you if you want it to fix the errors by adding binding redirect records in the app.config file. If you choose "yes", then Visual Studio adds some lines to the app.config file. Here's what it added for me:

<runtime>

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

<dependentAssembly>

<assemblyIdentity name="Microsoft.SharePoint.Library" publicKeyToken="71E9BCE111E9429C" culture="neutral"/>

<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="Microsoft.SharePoint" publicKeyToken="71E9BCE111E9429C" culture="neutral"/>

<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="Microsoft.SharePoint.Security" publicKeyToken="71E9BCE111E9429C" culture="neutral"/>

<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>

</dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="Microsoft.SharePoint.Dsp" publicKeyToken="71E9BCE111E9429C" culture="neutral"/>

<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>

</dependentAssembly>

</assemblyBinding>

</runtime>


Now just rebuild your project and try running it again... Everything should be working fine now!