如何在 Visual Studio 2010 vsto Clickonce 应用程序中将文件标记为数据文件?

发布于 2024-09-07 08:32:06 字数 273 浏览 1 评论 0原文

我正在 Visual Studio 2010 中使用 C# 4.0 制作 Word 2007 加载项。我需要通过 clickonce 安装程序将 Access 2007 数据库(.accdb 文件)放置在数据目录中。不幸的是,该文件被放在其他地方,因此应用程序在运行时无法找到它。我看过各种文章提到使用项目属性的“发布”选项卡上的“应用程序文件”对话框将文件标记为数据文件,但由于某种原因我没有“应用程序文件”按钮。

知道如何显示“应用程序文件”对话框,或者以其他方式手动将我的 .accdb 文件标记为数据文件吗?

I'm making a Word 2007 add-in with C# 4.0 in Visual Studio 2010. I need an Access 2007 database (a .accdb file) to be placed in the data directory by the clickonce installer. Unfortunately, the file is getting put elsewhere, so the application can't find it at runtime. I've seen various articles refer to using the Application Files dialog on the Publish tab of the project properties to mark the file as a data file, but I have no Application Files button for some reason.

Any idea how to make the Application Files dialog appear, or some other way to manually mark my .accdb file as a data file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

删除会话 2024-09-14 08:32:06

在解决方案资源管理器中,如果将文件的属性设置为“复制到输出目录”=“始终复制”。然后,当您转到应用程序文件时,它们应该默认为数据文件。

但是,由于这是您的数据库,我会考虑确保更新时安全,因此您可能会考虑这个帖子

请参阅 http://msdn.microsoft.com/en-us/library/dd465298 .aspx

顺便说一下,“应用程序文件”按钮应该位于项目属性的“发布”选项卡上。

In the Solution Explorer, if you set the file's property to be Copy to Output Directory = Copy Always. Then when you go to Application Files they should default as a Data File.

However, since this is your database I would consider looking at make it safe across updates so you might consider this post.

See http://msdn.microsoft.com/en-us/library/dd465298.aspx

By the way, "Application Files" button should be on the project properties' Publish tab.

还如梦归 2024-09-14 08:32:06

我能够通过使用 Mage 工具来完成工作,如下所述:

http ://msdn.microsoft.com/en-us/library/6fehc36e.aspx

MageUI 的技巧是它的打开文件对话框假设您要打开与 .exe 关联的清单; vsto 项目有一个 .dll,因此默认情况下清单不会出现在文件列表中,这确实让我很困惑。

基本上,这个过程很痛苦,因为你必须记住手动完成。我不知道是否有办法使这部分成为构建的一部分(也许是构建后步骤?但这实际上是发布后步骤)。

I was able to get things to work by using the Mage tool as described here:

http://msdn.microsoft.com/en-us/library/6fehc36e.aspx

The trick with MageUI is it's open file dialog assumes you want to open a manifest associated with a .exe; a vsto project has a .dll, so the manifest doesn't appear in the files list by default, which was really tripping me up.

Basically, this process is a pain because you have to remember to do it manually. I don't know if there's a way to make this part of the build (maybe a post-build step? But this is really a post-publish step).

望她远 2024-09-14 08:32:06

VSTO 应用程序没有可用的“应用程序文件”按钮,并且您无法专门设置文件类型。如果您的文件未部署到数据目录而您希望部署到数据目录,请使用 ClickOnce 标记为数据的文件扩展名对其进行重命名。这包括 .xml、.mdb 和 .mdf。否则,该文件将与 VSTO 应用程序一起部署,并将与其余文件位于同一位置。

可以通过以下方式以编程方式发现 VSTO 应用程序的部署文件的位置:

System.Reflection.Assembly.GetExecutingAssembly.CodeBase

不过,您可能希望移动数据库,因为除非将其部署为数据,否则当执行更新。

VSTO Applications do not have the Application Files button available, and you can't set the file types specifically. If your file is not being deployed to the data directory and you want it to be, rename it with a file extension that is marked by ClickOnce as data. This includes .xml, .mdb, and .mdf. Otherwise, the file is deployed with the VSTO application and will be in the same location as the rest of the files.

The location of the deployment files for a VSTO application can be discovered programmatically this way:

System.Reflection.Assembly.GetExecutingAssembly.CodeBase

You might want to move the database, though, because unless you deploy it as data, it will be lost when an update is performed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文