title: ASP.Net: MySQL Error SecurityException: System.Security.Permissions.SecurityPermission
body: <p>I am receiving the following error message:</p>
  
  <pre><code>Server Error in '/' Application.
  
  Security Exception
  
  Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 
  
  Exception Details: System.Security.SecurityException: System.Security.Permissions.SecurityPermission
  
  Source Error: 
  
  An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
  
  Stack Trace: 
  [SecurityException: System.Security.Permissions.SecurityPermission]
     MySql.Data.MySqlClient.MySqlClientFactory..cctor() +23
  
  Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
  </code></pre>
  
  <p>MySQL: mysql-connector-net-6.7.4</p>
  
  <p>The problem only occurs if run from the shared web hosting environment. The site works great locally. I know the version of the .Net connector that my shared hosting environment uses, as that was another issue that I resolved and I was in communication with the hosting provider.</p>
  
  <p>The error is interesting. I can go to the default page, no issues, the very first time. I then go to bring up a popup dialog, which throws another error message box.</p>
  
  <p>Exception has been thrown by the target of an invocation.</p>
  
  <p>The above is everything, except for the okay button.</p>
  
  <p>I can bring up the first popup, a sign in dialog, which comes up. That dialog does not invoke MySQL. I bring up the second dialog, a registration dialog, which then throws the "Exception has been thrown..." message box. After that, I cannot go back into the sign-in dialog, as I get the "Exception has..." message box. If I press F5 to refresh the browser (IE or Chrome), I get the error from above. The above error indicates MySQL and some permissions.</p>
  
  <p>I am suspecting that the "Exception has been thrown..." error is the result of the same MySQL, just the page has memory. Closing the browser window and launching the browser window again does not help, although on Chrome that works, just the browser window there really has to close down all the way.</p>
  
  <p>I am in a shared hosting environment, so I have access to basically nothing, so I do not have access to any logs, at least that I can think of.</p>
  
  <p>One final thought that may or may not be relevant. Yesterday and previous days my development work was done on a system with Windows 7 Professional and Visual Studio 2012 Professional (all latest service packs and updates), whereas today I am working at a different computer of mine, which is a system with Windows 8 Professional and Visual Studio 2012 Ultimate (all latest service packs and updates on the OS and VS). I was reading some other posts on unrelated issues that people with VS2012 Ultimate had issues, so I am not sure that has anything to do with it, but that is something that changed from yesterday to today.</p>
  
  <p>Yes, I deleted everything off of the server and uploaded everything anew. I did a clean solution first, built the release, and then published. I still received the same error.</p>
  
  <p>Any thoughts?</p>