Most pages that involve MySQL operations throw the following exception:
Server Error in '/'application.
Security Exception
Description: The application attempted to perform an operation not
Allowed by the security policy. To grant this application
Required permission please contact your system administrator or change
The application's trust level in the configuration file.
Exception details: system. Security.Securityexception: Request for
Permission of Type 'System. Security. permissions.Securitypermission,
Mscorlib, version = 2.0.0.0, culture = neutral,
Publickeytoken =B77a5c561934e089 'failed.
Source error:
[No relevant source lines]
Source File: app_web_bbkojzme.6.cs line: 0
Stack trace:
[Securityexception: Request for the permission of Type
'System. Security. permissions.Securitypermission, mscorlib,
Version = 2.0.0.0, culture = neutral, publickeytoken =B77a5c561934e089'
Failed.]
System. reflection. methodbase.Define msecuritycheck (Object OBJ,
Runtimemethodhandle method, intptr parent, uint32 invocationflags) + 0
System. reflection.Runtimeconstructorinfo. Invoke (Bindingflags
Invokeattr, binder, object [] parameters, cultureinfo Culture)
+ 470
System. runtimetype.Createinstanceimpl (Bindingflags bindingattr,
Binder binder, object [] ARGs, cultureinfo culture, object []
Activationattributes) + 1051
System. activator.Createinstance (type, bindingflags
Bindingattr, binder, object [] ARGs, cultureinfo culture,
Object [] activationattributes) + 111
System. Resources.ResourceManager.Createresourceset (Stream store,
Assembly) plus 357
System. Resources.ResourceManager.Internalgetresourceset (Cultureinfo
Culture, Boolean createifnotexists, Boolean tryparents) + 471
System. Resources.ResourceManager.Internalgetresourceset (Cultureinfo
Culture, Boolean createifnotexists, Boolean tryparents) + 583
System. Resources.ResourceManager.Internalgetresourceset (Cultureinfo
Culture, Boolean createifnotexists, Boolean tryparents) + 583
System. Resources.ResourceManager. getstring (String name, cultureinfo
Culture) + 74
MySQL. Data. mysqlclient.Resources. Get _Perfmoncategoryname () + 40
MySQL. Data. mysqlclient.Performancemonitor... ctor (Mysqlconnection
Connection) + 43
MySQL. Data. mysqlclient.Mysqlconnection. open () + 434
System. Data. Common.Dbdataadapter. quietopen (Idbconnection
Connection, connectionstate & originalstate) + 31
System. Data. Common.Dbdataadapter. fillinternal (Dataset dataset,
Datatable [] datatables, int32 startrecord, int32 maxrecords, string
Srctable, idbcommand command, commandbehavior behavior) + 112
System. Data. Common.Dbdataadapter. Fill (Dataset dataset, int32
Startrecord, int32 maxrecords, string srctable, idbcommand command,
Commandbehavior behavior) + 287
System. Data. Common.Dbdataadapter. Fill (Dataset dataset, string srctable) + 92
System. Web. UI. webcontrols.Sqlperformanceview.Executeselect (Datasourceselectarguments
Arguments) + 1297
System. Web. UI. performanceview.Select (Datasourceselectarguments
Arguments, performanceviewselectcallback callback) + 19
System. Web. UI. webcontrols.Databoundcontrol.Extends mselect () + 142
System. Web. UI. webcontrols.Basedataboundcontrol. databind () + 73
System. Web. UI. webcontrols.Gridview. databind () + 4
System. Web. UI. webcontrols.Basedataboundcontrol.Ensuredatabound () + 82
System. Web. UI. webcontrols.Compositedataboundcontrol.Createchildcontrols () + 72
System. Web. UI. Control.Ensurechildcontrols () + 87
System. Web. UI. Control.Prerenderrecursiveinternal () + 44
System. Web. UI. Control.Prerenderrecursiveinternal () + 171
System. Web. UI. Control.Prerenderrecursiveinternal () + 171
System. Web. UI. Control.Prerenderrecursiveinternal () + 171
System. Web. UI. Control.Prerenderrecursiveinternal () + 171
System. Web. UI. Page.Processrequestmain (Boolean
Includestagesbeforeasyncpoint, Boolean includestagesafterasyncpoint)
+ 6785
System. Web. UI. Page.Processrequest (Boolean
Includestagesbeforeasyncpoint, Boolean includestagesafterasyncpoint)
+ 242
System. Web. UI. Page.Processrequest () + 80
System. Web. UI. Page.Processrequestwithnoassert (Httpcontext context) + 21
System. Web. UI. Page.Processrequest (httpcontext context) + 49
ASP. news_aspx.processrequest (Httpcontext context) in app_web_bbkojzme.6.cs: 0
System. Web.Callhandlerexecutionstep.System. Web. httpapplication.Iexecutionstep. Execute ()
+ 181
System. Web. httpapplication.Executestep (iexecutionstep step,
Boolean & completedsynchronously) + 75
Version Information: Microsoft. NET Framework Version: 2.0.50727.4214;
ASP. NET version: 2.0.50727.4209
Solution:
To http://dev.mysql.com/downloads/mirror.php? Id = 393503 download MySQL for vs2008
Connector/NET 6.0.7. After the local machine is installed, upload the mysql. Data. dll file in the installation directory to the bin directory of the Godaddy server.
Modify the Web. config file:
<system.data> <DbProviderFactories> <clear/> <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.0.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> </DbProviderFactories> </system.data>
Upload the Web. config file to the Godaddy server.
See http://blog.csdn.net/reasoncool/article/details/6226920.