first of all, I would like to say that I have tried to resolve this issue for several hours through trying a bunch of different approaches from people that had the same issues, but to no avail. I am pretty clueless at this point.
I am using MySql.Data and MySql.Data.Entity dlls (version 6.7.4) which I have referenced in my ASP.NET 4.5 application.
I have managed to connect (locally) to my database and query it without a problem.
SqlConnection = new MySqlConnection("server=localhost;User Id=;Password=;database=;");
The problem is within a medium trust shared environment.
I get the following error (when attempting to connect to the database):
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: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
I have also tried to add "Integrated Security=True;includesecurityasserts=true;autoenlist=false;" to the connection string, but didn't help.
I have also tried to add this in my web.config:
<mscorlib>
<security>
<policy>
<PolicyLevel version="1">
<SecurityClasses>
<SecurityClass Name="MySqlClientPermission" Description="MySql.Data.MySqlClient.MySqlClientPermission, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</SecurityClasses>
<NamedPermissionSets>
<PermissionSet class="NamedPermissionSet" version="1" Name="ASP.Net">
<IPermission class="MySqlClientPermission" version="1" Unrestricted="true">
</IPermission>
</PermissionSet>
</NamedPermissionSets>
</PolicyLevel>
</policy>
</security>
But that did not work either.
I have then tried to add a bunch of PermissionSets, IPermissions and what not in the web.config by following some articles, but that didn't seem to work for me.
Please note:
Setting trust level="Full" in the web.config is not an option.
The connection string that I use to connect to the database is not in my web.config, and I would like to keep it that way.
Using anything else than MySql is not an option.
Any and all help is appreciated! Thank you!
EDIT
I have changed the way I communicate with the database with an ODBC connection.
Works properly using full trust, but as soon as I change to medium trust, I get basically the same error as with MySql connectors.
Request for the permission of type 'System.Data.Odbc.OdbcPermission, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Can anyone please point me to the right direction, such as a full example on how you managed to make it work, because I can't seem to make this work using medium trust...
Thanks!
I ended up using an ODBC connection.
Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase; User=myUsername;Password=myPassword;Option=3;
http://www.connectionstrings.com/mysql-connector-odbc-5-1/remote-database/
I know you tried the following solution:
Change the security from the web config to full trust.
Use the bin deployment (Copy to Local for dll property).
Change the trust level from assembly.
and so many other but no one is working.
you can not deploy this on medium trust. It required full trust for proper working.
May be you are using the medium trust server for deployment. You need full trust for the deployment. Only solution is you need to run it on Full trust environment. You need to contact with your server support and change the trust level medium to Full.
Here is how I solved a similar issue with trying to get MySql to work in a medium trust environment.
We tried everything to the ‘book’ and simply could not get it to work!
Turns out the MySql connecter version is the key. Ask you web hosting company what version of the MySqlClient they have installed on their server in GAC.
(GAC simply means the library is installed on the server so that it can be referenced directly and without you having to upload the MySql.Data.dll to your bin folder. The latest installable version is available here: http://dev.mysql.com/downloads/connector/net/).
Once the driver is installed on the server in GAC you just need to reference it in your web.config like this, but replace Version=6.6.5.0 with your web hosting companies version:
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
</assemblies>
</compilation>
Related
So when I publish my application I these following errors which I do not get in local mode.
"System.Security.SecurityException: Request for the permission of type
'System.Security.Permissions.SecurityPermission, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
failed."
So it is said that I'm supposed to write the following code in my Web.config to solve this first error:
<trustLevel name="Full">
So I did, but then, I got this error:
"This configuration section cannot be used at this path. This happens
when the site administrator has locked access to this section using
from an inherited configuration file."
It apparently has to do with the machine.config (which I cannot find)...
Does anyone have a proper solution for this?
If you wish to test it yourselves, here is the URL:
http://wideart.se/Exhibition
Regards
What is around <trustLevel name="Full"> ?
Is it inside system.web?
Try
<securityPolicy>
<trustLevel name="Full" policyFile="internal"/>
</securityPolicy>
so firstly, I get this error when publishing my web application:
"System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
So it is said that I'm supposed to write the following code in my Web.config:
<trustLevel name="Full">
So I did, but then, I got this error:
"This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using from an inherited configuration file."
At it has to apparently have to do with the machine.config (which I cannot find)...
Does anyone have a proper solution for this?
Regards,
I have problem with my ASP.NET MVC app which is using SQLSERVER 2012 Expresss for security and somehow this is conflicting with my Firebird installation which is not used in this case. Getting exception like this:
An error occurred creating the configuration section handler for system.data: Column 'InvariantName' is constrained to be unique.
Value 'FirebirdSql.Data.FirebirdClient' is already present.
I have tried to enter in my web.config this:
<remove invariant="FirebirdSql.Data.FirebirdClient"/>
but that didn't work, what I have finally do I have removed this firebird entry from machine.config:
<system.data>
<DbProviderFactories>
<add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Version=3.0.2.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c"/><add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Version=3.0.2.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c"/></DbProviderFactories>
and that worked out, but th is not ideal solution bcause I still need firebird to use sometimes. Anyway to disable this entry temporarily in app web,config? Also, why I am getting such conflict to start with anyway?
thanks
You have the same record in machine.config twice. Remove one and you'll be fine.
I have a similar problem and ended up with a different solution.
What happen is that I started developing my Web application in the default (root) folder IIS creates.
After that, for testing purposes I changed this option to work in a deeper folder in the same domain:
I added the name and clicked "Create Virtual Directory". The application ran but gave me the similar problem.
What happen is that when I created the second virtual directory IIS express leave the first one there pointing to the same location. So I have the same app twice sharing Web.config hierarchically.
Solution to my problem
To solve this I just changed the port so the previous created virtual directory is not my root anymore.
Problem
I'm getting the following error whenever I try to load out .svc url (Local)
Configuration binding extension 'system.serviceModel/bindings/pollingDuplexHttpBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.
Enviroment
The project was build by a ex colleague of mine, who I can't reach. It's a webservice build in .Net Framework 4
I get this error when I attempt to gain access to our .svc file
In the web.config I have this setting:
<system.serviceModel>
<extensions>
<bindingExtensions>
<add name="pollingDuplexHttpBinding" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement, System.ServiceModel.PollingDuplex, version=3.0.0.0, Culture=neutral" />
</bindingExtensions>
</extensions>
which is later used as <endpoint address="" binding="pollingDuplexHttpBinding" contract="<ourcompany>.DataService.IMessageService"/>
Attempts
In regards to other posts about this error I have already tried:
Installing Dot net 3.5 SP1
Removing the line from web.config
Reinstalled IIS
I have no idea what to do, or how to fix this.
The strange part is that it does work on our live server, but not on my own computer for testing purposes!
Refer - Unrecognized element 'pollingDuplexHttpBinding' in service reference configuration
<!-- Register the binding extension from the SDK. -->
<extensions>
<bindingExtensions>
<add name=
"pollingDuplexHttpBinding"
type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</bindingExtensions>
The difference here is, Version=4.0.0.0 and PublicKeyToken=31bf3856ad364e35.
You can get more information on the Section "To use PollingDuplexHttpBinding" section of - How to: Build a Duplex Service for a Silverlight Client.
Good luck. :)
I created a webservice when it hosted on my local computer it works fine, but when i publish it to the web host, it doesnt work any more, i guess its a question about how the webserver is configured, but can i make some changes in web.config so it will work?
The error i get is below:
Configuration Error
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 'MySql.Data, Version=5.0.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 37:
Line 38:
Line 39:
Line 40:
Line 41:
Source File: c:\webs\talkactive\gb1634\qaz.dk\web.config Line: 39
Assembly Load Trace: The following information can be helpful to determine why the assembly 'MySql.Data, Version=5.0.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' could not be loaded.
The webservice uses a c# class placed in the app_code folder. That c# class uses mysql.
When i use the class in a normal .aspx file it works fine
I guess the obvious thing would be to check whether the MySql.Data exist in the GAC (or the web service's bin folder) on the server and is of the correct version and public key?
Basically, you are missing this DLL. You should look at putting it in the bin directory of your webservice.
There could also be a versioning conflict between the MySql client you want and what is installed on the server. You can add the following section to your web.config file and specify the proper version/public key you need:
<compilation debug="false">
<assemblies>
<add assembly="MySql.Data, Version=5.0.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</assemblies>
</compilation>