简体   繁体   English

无需单击一次即可使用 localdb 发布 WPF 应用程序

[英]Publish WPF Application with localdb without click-once

i am a absolute beginner... and it is my first database based application.我是一个绝对的初学者......这是我的第一个基于数据库的应用程序。

i would like to drop a c# wpf application with database (2 tables) on an offline single-user-client.我想在离线单用户客户端上删除带有数据库(2 个表)的 c# wpf 应用程序。 its a wpf c# ef6 code first app.它是 wpf c# ef6 代码第一个应用程序。 on my machine with vs2019 it runs as intended.在我装有 vs2019 的机器上,它按预期运行。 now trying to run it on a new set up win10 machine it doesnt even start.现在尝试在新设置的 win10 机器上运行它,它甚至无法启动。

  • net 4.7.2 is installed净 4.7.2 安装
  • sql server 2016 localdb is installed manually (.msi) sql 服务器 2016 localdb 手动安装 (.msi)

Here is the connectionString for my db:这是我的数据库的连接字符串:

<connectionStrings>
<add name="ZuschnittverwaltungDB" connectionString="data source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|Datadirectory|\ZuschnittverwaltungDB.mdf;initial catalog=Zuschnittverwaltung.ZuschnittverwaltungDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />

i assume that i am missing a big point but i cant find any solution after searching several days...我认为我遗漏了一个重点,但在搜索了几天后我找不到任何解决方案......

Edit1:编辑1:

AttachDbFilename=|Datadirectory|\ZuschnittverwaltungDB.mdf -> AttachDbFilename=|Datadirectory|\ZuschnittverwaltungDB.mdf ->

AppDomain.CurrentDomain.SetData("DataDirectory", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));

i am thankfully for every approach.我很感激每一种方法。

It seems that everything i did first was right.看来我先做的一切都是对的。 Didnt changed the code or installed anything new.没有更改代码或安装任何新东西。

just ran cmd-> sqllocaldb delete mssqllocaldb刚刚运行 cmd-> sqllocaldb delete mssqllocaldb

copied the databasefiles from my pc to the specified folder and it worked...将数据库文件从我的电脑复制到指定的文件夹并且它有效......

Thanks @mm8.谢谢@mm8。 I could find more ErrorInformations in the windows event manager我可以在 windows 事件管理器中找到更多错误信息

cheers干杯

LocalDB is required to be installed separately on the client machine. LocalDB 需要单独安装在客户端机器上。

If you want to "drop" deploy your database along with the application itself you should use a self-contained database like SQLite .如果您想“删除”部署您的数据库以及应用程序本身,您应该使用一个独立的数据库,如SQLite

If you choose to stick with using LocalDB, you need to ensure that your database file is deployed to |Datadirectory|\ZuschnittverwaltungDB.mdf (or whatever path you have specified in the configuration file) on the target machine.如果您选择坚持使用 LocalDB,则需要确保将数据库文件部署到目标计算机上的|Datadirectory|\ZuschnittverwaltungDB.mdf (或您在配置文件中指定的任何路径)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM