开发者

How do I send a C# file in Visual Studio C# 2008 express edition along with the database in one zip file?

I have used Ms-Access(2000-2003) file format and Visual Studio C# Express 2008 Edition to create a WinForms application. I need to satisfy the following condition:

开发者_运维百科

All code and referenced assemblies must be submitted in one zip file. We need to be able to unzip and run the VS solution without changing settings, adding references or creating any databases.


You want the mdb to go with your executable, so:

  1. Place the Access mdb file into your solution by right clicking on the Project and using Add Existing Item.
  2. Once you have added the mdb file to your project, find it in Solution Explorer and right click on it and goto Properties.
  3. Once there change the Build Action to Content, and set Copy to Output Directory to Copy If Newer.
  4. Change any references to the mdb file to be relative--i.e. @"mydata.mdb"--as it will be copied alongside your EXE at compile time.

Now the database will follow your executable at compile and run whether you're in Debug or Release. This doesn't fix the situation where the target machine doesn't support Access, but that is not a problem you can solve through your project file.


I suggest you use a file based database such as SQL CE. This will make bundling the database with your application very easy.


Sounds like your project has external dependencies to a database server. In that scenario it's not possible to package that dependency along with the application. You can resolve the issue by removing your dependency on an external database server, and use a file based database instead (such as SQl Server Compact or SqlLite). Your dependency is then a single file, which is simple to deploy with the rest of your project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜