Publishing a Microsoft Access Application (mde) with Clickonce
So, a while ago I was looking for a better way to publish the Access database that I work on in my day-to-day business life.
I read over this page which goes over a couple of solutions, or there is the usual - setting up a login script, which is something we persevered with for some time.
And there are plenty of shareware loaders out there, and other utilities or coding pages, such as this one, that talk about building another front-end Access database and using that.
Instead I ended up starting to write my own in .NET and was getting it checked over by mabster when he pointed out something very simple and almost so easy I was banging my head on a table in frustration about how I could have not thought of it.
Use Clickonce.
So, for anyone unfamiliar with Clickonce, it is a simple way of deploying any Visual Studio/.NET application, where basically you install it and then whenever you make an update, all you have to do is hit the publish button - which then updates a website with your new release.
Then the next time people log into your program, they automatically check the versioning on the website and it tells them there is an update available.
Now there are two things that make this the most attractive method of doing an update:
- It's so darn simple.
- Clickonce comes with Visual Studio Express editions, so it comes free!
So basically, you have your compiled MDE, what do you do from there?
Well, you open up your copy of Visual Studio .NET (I'm going to give the instructions for the code in C# as I am fairly unfamiliar with VB in this day and age).
1. So you'll start a New Project of type Windows Application called Updater.
2. You can then delete the form1.cs from the solution - you will not need a Windows form for this.
3. You then want to open up the Program.cs code file and replace it with the following code:
using System;using System.Collections.Generic;using System.Windows.Forms;namespace Updater{static class Program{/// <summary>/// The main entry point for the application./// </summary>[STAThread]static void Main(){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);//Application.Run(new Form1());string datapath = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.DataDirectory;string myprogram = System.IO.Path.Combine(datapath, "My Access Database.mde");System.Diagnostics.Process.Start(myprogram);}}}
Then you can replace the "My Access Database.mde" with the name of your database.
4. You then want to right-click on your solution and Add Existing Items - choosing your Access MDE file you wish to deploy.
5. Click on the Access MDE file in your solution and look at the Properties tab. You want to set the Build Action to Content.
6. Right-click on the Solution name and look at its Properties.
7. Go to the Security tab.
(At this point you can also go to the Signing tab and add a security certificate to your published application. If you do not, your users will have a notice saying that your application may be insecure before they install).
8. Click the Enable ClickOnce Security Settings.
9. Make it a "This is a full trust application" the application will require this to install the mde.
10. Go to the Publish tab.
11. Choose a Publishing Location - this should be a web server either on your local network or online. You will need to enter a web site (if Frontpage front-end is on the server), or a ftp or file path.
12. Choose the Installation URL - this is the location people will go to, to install your application.
13. Be sure that the radio button for "The application is available offline as well" is selected.
14. Click the Application Files... button. Once there make sure that your mde is selected as both a Data File and as (Required).
15. Click the Prerequisites... button. Once there select "Create setup program to install prerequisite components".
From the list you will want to choose: ".NET Framework 2.0" and "Windows Installer 3.1" to make sure people have the latest components.
Special: Check the radio buttons on this page before proceeding.
If your Application is for deployment on a Local Network then you will want to choose "Download prerequisites from the same location as my application". This will automatically deploy the Framework and Windows Installer to the same web address as your application, so people can install them without going out to the internet.
If your application is for deployment on the Internet then you can just use "Download prerequisites from the component vendor's web site".
16. Click the Updates... button. Make sure that the "The application should check for updates" checkbox is selected, as well as "Before the application starts" radio button.
This will ensure that your program checks for updates each time the program starts.
17. Click the Options... button. The Publisher Name is the name of the menu directory under the Start Menu that the application will be saved in. The Product name is the name assigned to the icon/application that people will start.
18. Once you have done all this all you will need to do is press the Publish Now button to deploy your application.
Now people will need to go to the web address that comes up after the deployment is finished to install the Microsoft Access MDE launcher application.
The first thing the application will do is check back with that website to see if there is an update, and then it will start the MDE.
Whenever you need to update in the future, all you will need to do is replace the MDE in the solution directory with the update, open Visual Studio and your project, and then go back to the Publish tab and choose the Publish Now button again.
It might help if you open your Project File in Notepad and alter the path of the MDE stored in there to point to a shared place where you typically save your latest MDE. You can file the project file typically under: My Documents\Visual Studio 2005\Projects\Updater\Updater\Updater.csproj
It will be an XML file, and the code segment you will want to replace will look like this:
<Content Include="My Documents\Visual Studio 2005\Projects\Updater\Updater\My Access Database.mde"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>
And you will want to replace it with something like this:
<Content Include="L:\Updater\My Access Database.mde"><CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory></Content>
From there you can just keep creating your MDE at L:\Updater and each time you use ClickOnce to deploy it will use that copy of your MDE.
I also use this method to add other files to my application directory, such as Documentation and Forms that I want deployed and updated to my users hard drives along side the Access Application, and then let them start them up from inside the Access MDE.
You can also go and add icons for your application and other items if you wish.
I know it takes a little bit to set up, and it doesn't deploy automatically like a log in script - but your users will never again have the script not work, or cancel it during their boot. You won't have to muck about with creating extra Access front ends, or anything like that.
ClickOnce will maintain versioning for you, and you can have much better control over releasing your applications.
If you have any problems or would like to know something else, please leave a comment!

Comments
on on 8.29.2006 at 12:00 AM
Wow, that's a comprehensive post.
The best part about this idea, of course, is that it works for pretty much any kind of file, not just MDEs. You could use a similar tactic to deploy a non-managed EXE if you wanted!
Bob on on 11.23.2006 at 12:00 AM
Will the end user need MS Runtime Software to use the MDE?
on on 11.23.2006 at 12:00 AM
Hey Bob,
Yeah you still need the runtimes to run an MDE the same as usual.
This is just a better way of getting it out on peoples systems - and getting it consistantly updated.
loy on on 5.12.2009 at 2:59 PM
You said replace with the following code:
but i can not see your code.
plarisch on on 10.23.2009 at 1:39 AM
I wasn't able to see none of the published code on IE7, but a print preview showed and printed it to me
BINGO
jay on on 10.23.2009 at 6:50 AM
I do not see code when you say copy
"
You then want to open up the Program.cs code file and replace it with the following code "
there is empty space
would you please send me your code
thanks,
jay on on 10.24.2009 at 1:16 AM
plarisch
please send me code what you are able to get
what I got are not working
thanks
jay
jay on on 10.24.2009 at 1:21 AM
If any has running code please share
thanks
jay on on 10.24.2009 at 1:32 AM
Hi I found the way
just open this side in fire fox
and you will be able to see the code
thanks,
Andrew Tobin on on 10.24.2009 at 1:52 AM
Hey Jay,
Glad you figured it out - I apologise, I've been busy of late.
One thing I've done recently is compacted the mde with a gzip utility and used the built in .NET compression to decompress it on the end pc.
Doing that makes the MDE ~90% smaller - which is a huge difference.
Hope that helps.