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,
Related
while deploying Nopcommerce on server facing this issue,
Method 'ExecuteAsync' in type 'System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy' from assembly 'EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' does not have an implementation.
>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
>Exception Details: System.TypeLoadException: Method 'ExecuteAsync' in type 'System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy' from assembly 'EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' does not have an implementation.
>Source Error:
>The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
>1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%# Page Language="C#" Debug="true" %>
>or:
>2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
I building client server app.
The business logic is build in C++ /CLI.
In the same solution I have ASP.NET Web api project.
For logon i have method in backend. For logon i need to do this
using Back_End;
public IHttpActionResult Logon([FromBody]Logon_Request model)
{
string Answer = Back_End.Logon(model.Name, model.Password);
}
Back_End is inside of the dll in the same solution.
When I try to call api/logon it retunes me an exception.
{
"Message": "An error has occurred.",
"ExceptionMessage": "Could not load file or assembly 'Back_End, Version=1.0.5676.23091, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019)",
"ExceptionType": "System.IO.FileLoadException",
"StackTrace": ".........."
}
Of course, because it is not on IIS server.
Finally my questions:
-But do I need to deploy all my business logic dll on server?
-Will whey work here?
-Is any "better" way to do what I want?
-Maybe I need to sun it as a service and make calls? But it will be API for API.
Web.Config File
<compilation debug="true" targetFramework="yourTargetFramework">
<assemblies>
<add assembly="yourAssemblyName, Version=yourAssemblyVersion, Culture=neutral, PublicKeyToken=yourPublicKeyToken" />
</assemblies>
</compilation>
login.aspx page
<%# Register Assembly="yourAssemblyName, Version=yourAssemblyVersion, Culture=neutral, PublicKeyToken=yourPublicKeyToken" Namespace=".dll Namespace" TagPrefix="name to call the loginUserControl" %>
Ex.
...TagPrefix="rs" %>
<rs:Login/>
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>
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>
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>