October 31st, 2012, 09:45 PM
assembly reference not working in C# script
I'm trying to bring some assemblies into my bin folder for my website. I've got some C# script on the page that references and uses the assemblies. It looks like this:
I can create a new MySqlConnection object just fine but it's the System.Windows.Forms object (or namespace?) that's giving me trouble.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Windows.Forms" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="MySql.Data.MySqlClient" %>
void Page_Load(object sender, System.EventArgs e)
MySql.Data.MySqlClient.MySqlConnection con = new MySql.Data.MySqlClient.MySqlConnection();
Label1.Text = "hello world";
I found the dll in C:\Windows\Microsoft.NET\assembly\GAC_MSIL and copied it over to my wwwroot/bin/ folder.
The error I get when I try to load the page is:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'System.Windows.Forms' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
Line 57: <add assembly="System.EnterpriseServices, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Line 58: <add assembly="System.Web.Mobile, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
Line 59: <add assembly="*"/>
Line 60: <add assembly="System.Runtime.Serialization, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"/>
Line 61: <add assembly="System.IdentityModel, Version=184.108.40.206, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"/>
Source File: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Config\web.config Line: 59
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Windows.Forms' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Version Information: Microsoft .NET Framework Version:2.0.50727.5456; ASP.NET Version:2.0.50727.5456
So it says that the assembly I copied over was built more recently than whatever's already loaded (that's how I'm interpreting it at least). It tells me where the exact location of the problem is (line 59 in web.config) and that's where you see the <add assembly="*"/> but it doesn't tell me what to replace it with. It also tells me how to turn assembly binding logging off (whatever assembly binding means), but I don't seem to have the registry path it gives me on my computer.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!