Monday, February 22, 2010

AJAX Control Toolkit and .NET 4.0

If you would like to build a .NET 4.0 web application with Visual Studio 2010, and you would like to build the AJAX Control Toolkit from its source with .NET 4.0 as well, you may run into a little problem. Even though you can build the AJAX Control Toolkit itself just fine, but when you build your web application, the compiler will give an error: "Inheritance security rules violated by type: 'AjaxControlToolkit.TabPanelDesigner'. Derived types must either match the security accessibility of the base type or be less accessible."

A quick solution to this problem is to add the following to the "AssemblyInfo.cs" file of the AJAX Control Toolkit project (not your own web application project):

[assembly: SecurityRules(SecurityRuleSet.Level1)]

Of course, at the beginning of this file, make sure that you have

using System.Security;

After you have made these changes, rebuild the AJAX Control Toolkit, and then your web application. Your web application should build fine.

Update: A later build of AJAX Control Toolkit now works with Visual Studio 2010 without modification.

MySQL .NET Connector and .NET 4.0

Whe building a .NET 4.0 application with MySQL .NET Connector 6.2.2, you may get an 0x80131515 error from the SGEN utility, saying that the operation is not supported.

Apparently Visual Studio 2010 does not like the fact that the MySQL DLLs are pulled from the global assembly cache (GAC). If you add file references to these MySQL DLLs in your project, everything works.

To remove MySQL .NET Connector 6.2.2 from the GAC, you have to uninstall it. That is right: you have to uninstall it to use it!

After you uninstall MySQL .NET Connector 6.2.2 from the control panel, you can unzip the MySQL .NET Connector 6.2.2 zip file that you download from MySQL, and then place the files at a location that you can reference from your project.

Add references to these files in your project by browsing to them, you can then build your project with .NET 4.0 without errors.