“一键式”在Visual Studio 2013中部署C#/ WPF项目 [英] "One Click" Deployment of C#/WPF Project in Visual Studio 2013

查看:81
本文介绍了“一键式”在Visual Studio 2013中部署C#/ WPF项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一种学习经历,我试图将一个项目BookKeeper部署到CD / DVD(实际上我想看看我是否可以将它部署到一个拇指驱动器)。它不是商业应用程序,而是为我自己开发并作为学习体验而开发的应用程序。它是在Visual Studio 2013 Express上开发的C#/ WPF项目。我的计算机运行的是Windows 7.该项目使用SQL Server Express数据库,还包含一个映像。数据库的连接字符串是:



con.ConnectionString =Data Source = .\\SQLEXPRESS; AttachDbFilename =+| DataDirectory | \\\ \\MyDataBase.mdf; +Integrated Security = True; User Instance = True;





使用以下代码在XAML中打开图像:



< Image Canvas.Left =102Canvas.Top =122Width =400OpacityMask =#FFC2E5DB

Source =pack:// siteoforigin:,,, / Images / MyImage.png/>



对我而言,似乎我唯一的选择是部署此项目是一键式部署。在尝试一键式部署时,我遇到了困难。收到以下错误消息:



找不到文件'MyDataBase.mdf'

找不到文件'MyDataBase_log.ldf'

无法找到文件'Images\MyImage.png'



数据库位于根项目目录BookKeeper中,图像位于在启动一键式部署之前的子目录\Images,但在尝试部署后从这些目录中消失。我已经能够在生成的目录中找到数据库文件:



BookKeeper\bin\Release\app.publish\Application Files \BookKeeper_2_0_0_1 with添加了另一个扩展名:MyDataBase.mdf.deploy和MyDataBase_log.ldf.deploy(我在那里找不到图像)。



另外,当我尝试重建时解决方案,我收到相同的错误消息:



找不到文件'MyDataBase.mdf'

无法找到文件'MyDataBase_log。 ldf'

找不到档案'Images\MyImage.png'



但是我无法在任何地方找到数据库或图片项目文件,它们只是消失了。



我花了两周时间在网上寻求帮助,发现大量的帖子解决了相似但不完全相同的问题问题。大多数都是使用Windows XP使用Visual Studio 2012部署到Web站点。我尝试了一些建议的解决方案;他们要么不是特别相关,也没有解决我的问题。任何帮助将不胜感激。

As a learning experience I am attempting to deploy a project, "BookKeeper" to a CD/DVD (actually I’d like to see if I can deploy it to a thumb drive). It is not a commercial application but one developed for my own use and as a learning experience. It is a C#/WPF project developed on Visual Studio 2013 Express. My computer is running Windows 7. The project uses a SQL Server Express database and also contains one image. The connection string for the database is:

con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=" + "|DataDirectory|\\MyDataBase.mdf;" + "Integrated Security=True;User Instance=True";


The image is opened in XAML with the following code:

<Image Canvas.Left="102" Canvas.Top="122" Width="400" OpacityMask="#FFC2E5DB"
Source="pack://siteoforigin:,,,/Images/MyImage.png"/>

To me, it appears that the only option I have for deploying this project is "One Click" Deployment. Upon attempting the "One Click " deployment I have run into difficulties. receiving following error messages:

Could not find file ‘MyDataBase.mdf’
Could not find file ‘MyDataBase_log.ldf’
Could not find file ‘Images\MyImage.png’

The database is located in the root project directory, BookKeeper, and the image in a subdirectory \Images prior to initiating the "One Click" deployment but disappear from those directories after the attempted deployment. I have been able to locate the database file in a generated directory:

BookKeeper\bin\Release\app.publish\Application Files\BookKeeper_2_0_0_1 with a further extension added: MyDataBase.mdf.deploy and MyDataBase_log.ldf.deploy (I do not find the image there).

In addition, when I attempt "Rebuild Solution", I get the same error messages:

Could not find file ‘MyDataBase.mdf’
Could not find file ‘MyDataBase_log.ldf’
Could not find file ‘Images\MyImage.png’

But I cannot find the database or the image anywhere in the project files, they simply disappear into oblivion.

I’ve spent two weeks searching the net for help and found a large number of posts addressing similar but not quite the same problem. Most were directed toward deployment to Web sites, using Visual Studio 2012, using Windows XP. I’ve tried a number of the suggested solutions; they were either not particularly pertinent and did not resolve my problem. Any help would be greatly appreciated.

推荐答案

这可以帮助你 - 如何:在ClickOnce应用程序中包含数据文件 [ ^ ]。
This could help you - How to: Include a Data File in a ClickOnce Application[^].


这篇关于“一键式”在Visual Studio 2013中部署C#/ WPF项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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