Publish application with Entity Framework + Mysql

Asked

Viewed 2,266 times

4

I’m using the Entity Framework for Mysql.

I installed the .Net Connector, and the MySQL.Data.Entities.

Locally it is working normally. But when I go up to the LocaWeb, will not.

The following error appears:

Cannot perform CAS Asserts in Security Transparent methods

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.Invalidoperationexception: Cannot perform CAS Asserts in Security Transparent methods

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:

[Invalidoperationexception: Cannot perform CAS Asserts in Security Transparent methods]
Mysql.Data.Mysqlclient.MySqlClientFactory.. ctor() +24
Mysql.Data.Entity.MySqlEFConfiguration.. ctor() +73

[Targetinvocationexception: Exception has been thrown by the target of an Invocation. ] System.RuntimeTypeHandle.Createinstance(Runtimetype type type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached,

My Web.config:

 <connectionStrings>
        <add name="BancoDados" providerName="MySql.Data.MySqlClient" connectionString="Data Source=xxxx; port=3306; Initial Catalog=bancoMySQL; uid=usuarioMySQL; pwd=qwe123qwe;" />
      </connectionStrings>
<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
    </providers>
  </entityFramework>

I started doing some research and came up with a reference from LocaWeb: Locaweb on the topic:

Mysqlconnector / Unable to find the requested . Net Framework Data Provider. It may not be installed

So by doing what you say on the topic, I added

And

  <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.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
        </DbProviderFactories>
    </system.data> 

But it had no effect.

I even found a page on the Internet, but I didn’t quite understand the procedure I was talking about, and I think it’s the same one that recommends Locaweb, but I’ll leave the LINK

  • 3

    Locaweb? I will pray for your soul.

  • You did Copy Local = True on Dlls prior to publication?

  • @Ciganomorrisonmendez, in ALL Dlls or only which refer to Mysql?

  • The ideal was all because Locaweb is boring for everything.

  • @Gypsy omorrisonmendez, still same mistake!!!

  • I don’t know much about Locaweb, but there is the possibility of registering Assemblies in the machine’s GAC?

  • @Ciganomorrisonmendez, no... As far as I know no, the only thing I can do is upload files... hahaha!

  • Well, here’s the thing: that mistake means that Assembly cannot be fully enforced by safety restrictions. I think that in this case it is best to contact Locaweb support to ask for guidance directly for them. You can’t answer that because it can be many things, and you don’t have a single solution.

  • Really personal, at Locaweb only works with the Mysqlconnector version below the 6.3.

Show 4 more comments

2 answers

1

I’ve suffered enough with it!

At Locaweb, it only works with the Mysqlconnector version below 6.3 or 5.3, I don’t remember right!

Just download the old Nector, replace the dll, and change their versions on the web.config! It’s the only way!

At the time, I was so angry, that I was migrating some websites to the Hotel da Web that has already included the SQL Server database!

  • I tried to download the Connector 5.3 only that it comes only as executable... How do I get his dll’s? And the Publickey in webconfig, remains the same?

  • You will probably find in C: Program Files (x86) Mysql

  • Today, the current version of Locaweb is 5.1

0

Good morning buddy,

I went through this problem and solved with the staff of Locaweb, just adding the line includesecurityasserts=true between the parameters of webconfig in the string Connection, simple.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.