Can VB.NET Installation include 2007 MS Access Database Engine?
-
Friday, December 16, 2011 6:22 PMIt used to be that the VB6 installation tool automatically recognizes a MS Access dependency and includes the appropriate DLL(s). In VB.Net (2008) I am struggling with the concept of having to have two different installations, one for my tool and one for the 2007 MS Access Database Engine... Can you tell me if there is at least a way of manually including the appropriate Database Engine Files in my application installation?
JP Brazill- Moved by Allen Li - AI3Microsoft Contingent Staff Monday, December 19, 2011 3:29 AM (From:ADO.NET Managed Providers)
All Replies
-
Monday, December 19, 2011 1:49 PM
See if the below link helps:
Paul ~~~~ Microsoft MVP (Visual Basic) -
Monday, December 19, 2011 7:26 PM
Hi Paul,
Thanks for your reply. I should have mentioned that I have a windows installer project, not click once, that needs to install the access 2007 components. I am confused in that it appears as though the access 2007 primary interop IS NOT what needs to be installed but whatever AccessDatabaseEngine.exe contains. I attempted to include it as a custom action but end up with an error 1500 (because the initial MSI is already running). I also don't know if there is any way to include it as a prerequisite because I don't know what files are actually contained in AccessDatabaseEngine.exe. Hook-em Horns.
JP Brazill -
Tuesday, December 20, 2011 11:39 AMModerator
Hi Jp Brazill,
Welcome to the MSDN Forum.
Based on your description, it seems that you are attemp to make a windows installer, and you need to add a few prerequisites in the installer.
If I am correct, please take a look at this article: http://msdn.microsoft.com/en-us/library/7eh4aaa5(v=VS.100).aspx
It provides a very detailed steps about how to add such prerequisites.
I hope it is helpful.
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
Monday, December 26, 2011 4:50 PM
All,
It is very disappointing that something that should be as simple as the setup wizard detecting an Access dependency is not included in the system. You cannot include AccessdatabaseEngine.exe as a prerequisite and you cannot include AccessdatabaseEngine.exe directly as a custom action (you end up with an error 1500 as two instances of (windows installer?) cannot run at the same time. The solution, it seems, is to write custom installation code in your main primary output project and trigger it from a custom action in the setup project in the solution. Thanks to Yogi's article: http://techieyogi.blogspot.com/2009/11/installing-access-database-engine-with.html
Here are the steps to follow for a VB.NET (2008), Access 2007 windows installer solution:
1) With the application solution open (the one that has the project you intend to distribute), add a new item (right click on the solution tree item in the solution explorer and select Add/New Item). In the Categories tree select CommonItems/General. In the Templates listview select Installer Class under Visual Studio Installed Templates. In the name field below, the default is Installer1.vb and I renamed it to "AccessInstallationCode.vb".
2) Paste the following code in AccessInstallationCode.vb (initially translated to VB from Yogi's C# code):
Imports System.ComponentModel
Imports System.Configuration.Install
Imports System.IOPublic Class AccessInstallationCode
Dim AccessComponentFile As String = "AccessDatabaseEngine.exe"
Public Sub New()
MyBase.New()
'This call is required by the Component Designer.
InitializeComponent()'Add initialization code after the call to InitializeComponent
End Sub
Public Overrides Sub Install(ByVal stateSaver As IDictionary)
MyBase.Install(stateSaver)
End Sub
Private Sub AccessInstallationCode_AfterInstall(ByVal sender As Object, ByVal e As System.Configuration.Install.InstallEventArgs) Handles Me.AfterInstall
Dim str As String = System.Reflection.Assembly.GetExecutingAssembly().Location
Dim ex As Exception
Dim i As Integer = str.LastIndexOf("\"c)If AccessDatabaseEngineInstalled() Then
Exit Sub
End IfDim prc = New System.Diagnostics.Process()
str = str.Substring(0, i)
Try
prc.StartInfo.FileName = str & "\" & AccessComponentFile
'prc.StartInfo.Arguments = "/quiet"
prc.Start()
prc.EnableRaisingEvents = True
AddHandler prc.Exited, New EventHandler(AddressOf prc_Exited)Catch ex
System.Windows.Forms.MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End TryEnd Sub
Private Sub prc_Exited(ByVal sender As Object, ByVal e As EventArgs)
Dim str As String = System.Reflection.Assembly.GetExecutingAssembly().Location
Dim ex As ExceptionDim i As Integer = str.LastIndexOf("\"c)
str = str.Substring(0, i)Dim FolderPath As String = str & "\" & AccessComponentFile
If File.Exists(FolderPath) Then
Try
File.Delete(FolderPath) 'DONT DO THIS afterall!!! See my explanation in this thread below!
Catch ex
System.Windows.Forms.MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End SubPrivate Function AccessDatabaseEngineInstalled() As Boolean
Dim FileName1 As String 'Location Prior to Windows 7
Dim FileName2 As String 'Location for Windows 7 (Not sure if this file location is for the 64bit version of Windows 7 only)FileName1 = "C:\Program Files\Common Files\microsoft shared\OFFICE12\ACECORE.DLL"
FileName2 = "C:\Program Files (x86)\Common Files\microsoft shared\OFFICE12\ACECORE.DLL"If File.Exists(FileName1) Or File.Exists(FileName2) Then
Return True
Else
Return False
End IfEnd Function
End Class
NOTE: I have commented out the argument to have the AccessDatabaseEngine install in quiet mode, you can uncomment this line out as your preference.
3) Add a setup project to your main project solution. Rightclick on the setup project in solution explorer and select Add/Project Output. In the dialog select Primary Output.
4) Open the File System tab for the setup project. Rightclick the Application Folder (Under File System for Target Machine) and select Add/File. Select AccessDatabaseEngine.exe (you can download it from microsoft: http://www.microsoft.com/downloads/details.aspx?familyid=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en and put it in an appropriate Windows folder such as your project root).
5) Also add your database file ([applicationdb].accdb) to the Application Folder.
6) Add any shortcuts (for your application exe) you want to User's Desktop and User's Programs Menu.
7) Open the Custom Actions Editor for the setup project, Rightclick on Install in the tree and select Add Custom Action... In the Look In dropdown, select Application Folder then select Primary Output from (your application name).
8) Build your application project first then build your setup project. AccessDatabaseEngine.exe will be included in the setup.msi file and will be included in the application folder on the target machine, then will be triggered after the primary installation has completed.
There is one issue remaining. From the microsoft forum thread 2007 Office System Driver Exists?(http://social.msdn.microsoft.com/Forums/en/innovateonoffice/thread/9176af77-f045-47ad-946f-ed4357d7ac84), I coded the function AccessDatabaseEngineInstalled. I am used to checking the registry in such cases and wonder if this is a bonafide method to use?
JP Brazill
- Edited by John Brazill Tuesday, December 27, 2011 4:13 AM
- Proposed As Answer by Mike FengMicrosoft Contingent Staff, Moderator Tuesday, December 27, 2011 7:46 AM
- Edited by John Brazill Tuesday, December 27, 2011 7:21 PM
- Edited by John Brazill Friday, December 30, 2011 9:36 PM
- Edited by John Brazill Friday, December 30, 2011 9:39 PM
- Marked As Answer by Mike FengMicrosoft Contingent Staff, Moderator Tuesday, January 03, 2012 12:56 PM
- Edited by John Brazill Friday, March 02, 2012 3:48 AM
-
Tuesday, December 27, 2011 7:46 AMModerator
Hi John,
First of all, I really appreciate you to sharing your solution here. Thank you.
>>if this is a bonafide method to use?
What do you mean about "bonafide method"?
Generally, to check a program is installed or not, we can check the special folder or special file(As the thread you mentioned) or check the registry(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall), the display name and unstall string should be the checkpoint. So you can follow one of the three ways.
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked As Answer by Mike FengMicrosoft Contingent Staff, Moderator Tuesday, January 03, 2012 12:56 PM
-
Friday, March 02, 2012 3:45 AM
All,
I stumbled on an oddity that is worth mentioning here and if anyone has an explaination as to why it happens, I would be very interested to know.
The solution I posted above deletes the AccessDatabaseEngine.exe file from the application folder when it has been executed and the process ended.
I have been encountering something really strange ever since. The windows installer setup program also puts shortcuts to the application on the desktop and in a start/programs menu. Whenever I launch the program from either of these two links, I get indications that the windows installer fires up again... says gathering required information, configuring, etc. The dialog lasts for just a bit then my application launches... What was weird is that if I double click on the exe in windows explorer, this phoenomenon does not occur. Anyway I discovered that if the MSI is no longer there, the windows installer chokes (and I am assuming it is MSIEXEC) and the application will not launch... BAD!
Well, I discovered that if I do NOT delete the AccessDatabaseEngine.EXE file through the code above (see Sub prc_Exited), the app directly launches normally as one would expect. So I am concluding that something underneath the covers, like some sort of manifest, is being checked by something contained in the link (shortcut) and if something is not right (like a missing file the installer originally put in the application folder), it attempts to launch the original installer (MSI file) to correct. The missing file is indeed put back into the application folder but because of an additional piece of code (not included above) in the event that Access IS already installed I was deleting the file there as well.
But the main point is I would like to understand more about what actually triggers the installer to run in this event and to issue a warning to ALL about what will happen if the post install action deletes a file that is put there by the installer and the MSI is no longer available. I ran an additional experiment by manually deleting an icon file (innocuous content) though windows explorer and sure enough the installer fired up when I launched the app from the shortcut and it put the icon file right back in.
JP Brazill
-
Tuesday, August 21, 2012 3:45 PM
I am getting an error in the AccessInstallationCode_AfterInstall event
This is the error:
Error 3 'Exited' is not an event of 'Object'. C:\Users\sconnor\Documents\Visual Studio 2008\Projects\C3Wizard\C3Wizard\AccessInstallationCode.vb 44 28 C3Wizard
This is the code that is generating the error
Private Sub AccessInstallationCode_AfterInstall(ByVal sender As Object, ByVal e As System.Configuration.Install.InstallEventArgs) Handles Me.AfterInstall
Dim str As String = System.Reflection.Assembly.GetExecutingAssembly().Location
Dim ex As Exception
Dim i As Integer = str.LastIndexOf("\"c)
If AccessDatabaseEngineInstalled() Then
Exit Sub
End If
Dim prc = New System.Diagnostics.Process()
str = str.Substring(0, i)
Try
prc.StartInfo.FileName = str & "\" & AccessComponentFile
'prc.StartInfo.Arguments = "/quiet"
prc.Start()
prc.EnableRaisingEvents = True
AddHandler prc.Exited, New EventHandler(AddressOf prc_Exited)
Catch ex
System.Windows.Forms.MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub -
Tuesday, August 21, 2012 5:43 PM
Hello,
I'm not sure I can help you... The first thing I would ask is if you have
Private Sub prc_Exited(ByVal sender As Object, ByVal e As EventArgs) also specified.
As I stated in my post, this was originally adapted from Yogi's article:
http://techieyogi.blogspot.com/2009/11/installing-access-database-engine-with.htmlIt works for me, I have not run into this error...
Sorry.
JP Brazill

