WPF应用程序在其他计算机上不起作用 [英] WPF application doesn't work in other computers

查看:456
本文介绍了WPF应用程序在其他计算机上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个简单的WPF应用程序,只是为了获得一些经验。
所有这些都是在用户点击按钮时从数据库获取信息。

该应用程序在我的PC上正常工作(使用发布选项),但是当我尝试在我的笔记本电脑和我的朋友的电脑,应用程序崩溃一样快按钮被按下。

我99%确定它与实体框架有关,我用来联系数据库(所有在按钮上点击的功能被触发并从数据库检索信息)。



在google中找到答案后,我发现它可能与PC中的.net安装或项目引用有关。



但是,.net FW版本在我的电脑和笔记本电脑中是一样的,引用都被标记为copy-local(仅供测试!) / p>

还有什么可能导致这样的问题?我真的不知道...



更新



我发现我得到的错误是:

在配置中找不到指定的商店提供商,或无效。



我也通过在Google中进行更深入的搜索来解决这个问题。

解决方案可以在下面找到...



快乐编码!

解决方案

我终于解决了!



这是怎么做的:

1)确保你的项目有一个对MySql.Data.dll,MySql.Web.dll,MySql.Data.Entity.dll和System.Data.Entity的引用.dll。



2)将以上所有内容全部复制到本地。



3)添加以下内容行到您的 App.config 文件:

 < system.data> ; 
< DbProviderFactories>
< clear />
< add name =MySQL数据提供者invariant =MySql.Data.MySqlClient
description =。用于MySQL的Net Framework数据提供者
type =MySql.Data.MySqlClient .MySqlClientFactory,MySql.Data,
Version = 6.4.4.0,Culture = neutral,PublicKeyToken = c5687fc88969c44d/>
< / DbProviderFactories>
< /system.data>

4)点击MySQL.Data参考,并检查它的版本。您可以在选择它之后在解决方案资源管理器的属性窗口中找到。



5)更改 Version = 6.4.4.0 部分到您的MySql.Data.dll的版本。矿井是6.5.4.0,这是最新的,但是较旧的版本应该是一样好。



另外,我要感谢 Ralf de Kleine 和其他所有回答提出/提示异常代码的人。

当我们这么简单的时候,我不想考虑使用异常!


I have built a simple WPF application just to gain some experience with it. All it does is get information from a database when a user clicks on a button.
The application works fine in my PC(using the publish option), but when I tried running it on my laptop and my friends' PC, the app crashed as fast as the button was pressed.
I'm 99% sure it has something to do with Entity Framework, which I use to contact the database (all the the function that gets fired on the button click does is contact and retrieve info from the DB).

After looking for answers in google I found out that it may have something to do with either the .net installation in the PC, OR the project references.

However, the .net FW version is the same in my PC and my laptop, and the references were all marked as copy-local (just for testing!).

What else could cause such problem? I really have no idea anymore...

UPDATE

Using exceptions, I found out that the error I got was:
The specified store provider cannot be found in the configuration, or is not valid.

I also solved this problem by searching deeper in Google.
The solution can be found below...

Happy coding!

解决方案

I finally solved it!

This is how to do it:
1) Make sure your project has a reference to MySql.Data.dll, MySql.Web.dll, MySql.Data.Entity.dll and System.Data.Entity.dll.

2) Set all of the above to Copy-Local.

3) Add the following lines to your App.config file:

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

4) Click on the MySQL.Data reference, and check it's version. It can be found in the 'Properties' window below the solution explorer after you select it.

5) Change the Version=6.4.4.0 part to the version of your MySql.Data.dll. Mine was 6.5.4.0 which is the newest but older versions should work just as fine.

Also, I'd like to thank Ralf de Kleine and everyone else who answered for putting up/suggesting the exception code.
It was dumb of me to not think about using exceptions when they're just so convenient!

这篇关于WPF应用程序在其他计算机上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆