问题
I encountered this error on host.
System.InvalidOperationException: Cannot perform CAS Asserts in Security Transparent methods
at System.Security.CodeAccessSecurityEngine.CheckNReturnSO(PermissionToken permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 create)
at System.Security.SecurityRuntime.Assert(PermissionSet permSet, StackCrawlMark& stackMark)
at System.Security.PermissionSet.Assert()
at MySql.Data.MySqlClient.MySqlParameter.SetTypeFromValue()
at MySql.Data.MySqlClient.MySqlParameter.set_Value(Object value)
at MySql.Data.MySqlClient.MySqlParameter..ctor(String parameterName, Object value)
But in localhost project succesfully run.I'm using asp.net 4.0 and mysql.In some resources say I have to change trust level but I cannot change.Because my hosting firm doesn't allow web config file change for this subject.How can I change trust level without web config change.How can I solve this problem? Thanks in advance
回答1:
I guess you are using a shared host, so there's no way you can changed trust level if they don't give you permissions to do it.
What versions of the MySQL connector are you using? Have you tried copying them to the \bin folder of your project? (right-click on MySQL.* references and setting then to "Copy Local = true")
Are you able to try to connect to your database server from localhost to make sure your connection string parameters are ok?
来源:https://stackoverflow.com/questions/17095120/cannot-perform-cas-asserts-in-security-transparent-methods-security-level-issue