如何在 Raspberry pi 2(Mono 4 + ARM proc)上部署 npgsql? [英] how to deploy npgsql on Raspberry pi 2 (Mono 4 + ARM proc)?
问题描述
我使用 Visual Studio 2013 (Windows) 构建一个使用 Npgsql 和实体框架 6 的小型 .NET 4.5 应用程序.
I use Visual studio 2013 (Windows) to build a small .NET 4.5 application using Npgsql and Entity Framework 6.
在 Windows 上它运行良好.但是在 Raspbian 上,应用程序崩溃说它找不到 npgsql 提供程序.
On windows it just works fine. But on Raspbian, the app crash saying it cannot find npgsql provider.
Unhandled Exception:
System.Configuration.ConfigurationErrorsException: Failed to find or load the registered .Net Framework Data Provider 'Npgsql'.
at System.Data.Common.DbProviderFactories.GetFactory (System.String providerInvariantName) [0x00000] in <filename unknown>:0
[...]
在我的树莓派 2 上.
On my raspberry pi 2.
我已经手动安装了 Mono v4.0.2
I have manually installed Mono v4.0.2
我复制了我的应用,包括:
I have copied my app including:
npgsql.dll v2.2.5.0
npgsql.dll v2.2.5.0
npgsql.entityframework 相同版本
npgsql.entityframework same version
mono.security v4.0.2
mono.security v4.0.2
我的 app.config 包含:
and my app.config contains :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<providers>
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
</providers>
</entityFramework>
<connectionStrings>
<add name="minitestEntities" connectionString="metadata=res://*/Model2.csdl|res://*/Model2.ssdl|res://*/Model2.msl;provider=Npgsql;provider connection string="PORT=5432;TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE=2.2.5.0;DATABASE=minitest;HOST=10.0.0.1;INTEGRATED SECURITY=True;PASSWORD=azerty;USER ID=theuser"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
所以我想知道 npgsql 库是否正确加载,或者是否缺少引用.
So i'm wondering if npgsql librairies are correctly loaded, or a if a reference is missing.
我没有找到有关如何在最近的单声道 + ARM 环境中使用 npgsql 的文档.任何有关这方面的信息将不胜感激.
I found no docs on how to use npgsql on recent mono + ARM environment. Any info about this would be really appreciated.
推荐答案
好的,我在其他讨论中找到了解决方案.与此同时,我忘了记下它的 URL,所以这里的答案是:
ok i found the solution in an other discution. In the meanwhile i forgot to note its URL so here the answer :
我们必须手动将提供者描述添加到 app.config 中:
We have to add manually the provider description into app.config :
<system.data>
<DbProviderFactories>
<add name="Npgsql Data Provider"
invariant="Npgsql"
support="FF"
description=".Net Framework Data Provider for Postgresql Server"
type="Npgsql.NpgsqlFactory, Npgsql, Version=2.2.5.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
</DbProviderFactories>
</system.data>
版本和 PuclicKeyToken 必须与 npgsql.dll 匹配.要获取公钥令牌,您可以运行该代码:
The version and PuclicKeyToken MUST match with npgsql.dll. To get the public key token, you can run that code :
typeof(Npgsql.NpgsqlFactory).AssemblyQualifiedName
现在我不知道为什么这一步在 windows 中不是必需的,但在 linux 中必须要做...
Now i have no idea why this step is not necessary into windows, but a have to do into linux...
这篇关于如何在 Raspberry pi 2(Mono 4 + ARM proc)上部署 npgsql?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!