0

我有一个必须在单声道上运行的 MySql 数据库控制台应用程序的错误。在 microsoft 的 .NET 上它运行完美,但在 Mono 2.11.4 上它就无法工作。

我已经尝试将引用的大部分“复制本地”设置设置为“true”,但无济于事。

在应用程序开始时,我立即得到以下异常:

Unhandled Exception:

System.TypeInitializationException: An exception was thrown by the type initializer for System.Data.Entity.ModelConfiguration.Utilities.TypeExtensions ---> System.InvalidProgramException: Invalid IL c
ode in System.Data.Metadata.Edm.PrimitiveType:GetEdmPrimitiveTypes (): method body is empty.

  at System.Data.Entity.ModelConfiguration.Utilities.TypeExtensions..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Data.Entity.Internal.DbSetDiscoveryService.GetSets () [0x00000] in <filename unknown>:0
  at System.Data.Entity.Internal.DbSetDiscoveryService.InitializeSets () [0x00000] in <filename unknown>:0
  at System.Data.Entity.DbContext.DiscoverAndInitializeSets () [0x00000] in <filename unknown>:0
  at System.Data.Entity.DbContext.InitializeLazyInternalContext (IInternalConnection internalConnection, System.Data.Entity.Infrastructure.DbCompiledModel model) [0x00000] in <filename unknown>:0
  at System.Data.Entity.DbContext..ctor (System.String nameOrConnectionString) [0x00000] in <filename unknown>:0
  at oldforum2vanille.NewForum.vforumEntities1..ctor () [0x00000] in <filename unknown>:0
  at oldforum2vanille.Program.ConvertDiscissionTopics (Int32 newforumid, System.String forumtitle) [0x00000] in <filename unknown>:0
  at oldforum2vanille.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Data.Entity.ModelConfiguration.Utilities.TypeExtensions ---> System.In
validProgramException: Invalid IL code in System.Data.Metadata.Edm.PrimitiveType:GetEdmPrimitiveTypes (): method body is empty.

  at System.Data.Entity.ModelConfiguration.Utilities.TypeExtensions..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Data.Entity.Internal.DbSetDiscoveryService.GetSets () [0x00000] in <filename unknown>:0
  at System.Data.Entity.Internal.DbSetDiscoveryService.InitializeSets () [0x00000] in <filename unknown>:0
  at System.Data.Entity.DbContext.DiscoverAndInitializeSets () [0x00000] in <filename unknown>:0
  at System.Data.Entity.DbContext.InitializeLazyInternalContext (IInternalConnection internalConnection, System.Data.Entity.Infrastructure.DbCompiledModel model) [0x00000] in <filename unknown>:0
  at System.Data.Entity.DbContext..ctor (System.String nameOrConnectionString) [0x00000] in <filename unknown>:0
  at oldforum2vanille.NewForum.vforumEntities1..ctor () [0x00000] in <filename unknown>:0
  at oldforum2vanille.Program.ConvertDiscissionTopics (Int32 newforumid, System.String forumtitle) [0x00000] in <filename unknown>:0
  at oldforum2vanille.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

我已经在http://alpascual.com/post/2011/05/27/Error-Unable-to-find-the-requested-Net-Framework-Data-Provider-It-may-not-尝试了一个建议的解决方案be-installed.aspx(因为他的错误信息大致相等)所以我将这些行添加到我的 app.config

<system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data" />
      <add name="ADO.Net driver for MySQL" invariant="MySql.Data" description="ADO.Net driver for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data.MySqlClient, Version=6.6.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
</system.data>

在对配置进行了一些修改之后,由于这些行,Entity Framework 现在再次使用 MySql,但 Mono 只是跳过了此配置并再次给出了上述 Unhandled Exception。:(

大家有什么想法吗?我是不是忘记了什么?

4

1 回答 1

1

这不是 Mono 支持的方案。您不应该使用 Mono 运行 Microsoft 实现特定的运行时库,例如 System.Data.Entity.dll。

Entity Framework 最近已经开源(6.0 版),它与最新的 Mono 版本捆绑在一起。Mono 不支持早期版本的实体框架。

于 2012-10-01T19:27:44.337 回答