简体   繁体   中英

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. its a wpf c# ef6 code first app. on my machine with vs2019 it runs as intended. now trying to run it on a new set up win10 machine it doesnt even start.

  • net 4.7.2 is installed
  • sql server 2016 localdb is installed manually (.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:

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

copied the databasefiles from my pc to the specified folder and it worked...

Thanks @mm8. I could find more ErrorInformations in the windows event manager

cheers

LocalDB is required to be installed separately on the client machine.

If you want to "drop" deploy your database along with the application itself you should use a self-contained database like 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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