MySql Connector/Net and ASP.Net medium trust

Anyone doing this? I can't get MySql Connector/Net to work unless i set asp.net at full trust.

Output is: Exception Details: System.Security.SecurityException: Security error.

Output also hints about adding Debug="true" in the web.config, which don't have any impact at all.

This is what i have done so far;

Installed connector with installer from mysql.com

Added assembly to machine.config with:

Code:
<add assembly="MySql.Data, Version=1.0.4.20163, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
which made it work in full trust.

After that changed to medium and no go.

This is the source i tested:
Code:
<%@ Page Language="VB" debug="true" %>
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "MySql.Data.MySqlClient" %>
<script language="VB" runat="server">

Sub Page_Load(sender As Object, e As EventArgs)

    Dim myConnection  As MySqlConnection
    Dim myDataAdapter As MySqlDataAdapter
    Dim myDataSet     As DataSet

    Dim strSQL        As String
    Dim iRecordCount  As Integer

    myConnection = New MySqlConnection("server=localhost; user id=UID; password=PW; database=DB; pooling=false;")

    strSQL = "SELECT * FROM mytable;"

    myDataAdapter = New MySqlDataAdapter(strSQL, myConnection)
    myDataSet = New Dataset()
    myDataAdapter.Fill(myDataSet, "mytable")

    MySQLDataGrid.DataSource = myDataSet
    MySQLDataGrid.DataBind()

End Sub

</script>

<html>
<head>
<title>Simple MySQL Database Query</title>
</head>
<body>

<form runat="server">

<asp:DataGrid id="MySQLDataGrid" runat="server" />

</form>

</body>
</html>

 

 

 

 

Top