468,549 Members | 2,042 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,549 developers. It's quick & easy.

An exception occurred in the OnBeforeInstall event handler of <name> Access to the path <path> is denied.

Hello I am developing a Windows Ce 5.0 mobile application. I followed the
example shown at :

Creating Self-Updating Applications With the .NET Compact Framework
http://msdn2.microsoft.com/en-us/library/aa446487.aspx

I was able to build the Cab file installer and Setup for the application
just fine and I created the CustomInstaller in VB rather than C# in the
example.

However on running of the Setup.exe file I receive the error:

"An exception occurred in the OnBeforeInstall event handler of
<application name>InstallDLL.CustomInstaller. --Access to the path
'C:\Windows\system32\TEMP\<application name>\InstallDLL.dll' is denied."

Here is the CustomInstaller class for reference

Imports System.ComponentModel
Imports System.Configuration.Install
Imports System.IO
Imports Microsoft.Win32
Public Class CustomInstaller

Private Const CEAPPMGR_PATH As String =
"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\CEAPPMGR.EXE"
Private Const ACTIVESYNC_INSTALL_PATH As String =
"SOFTWARE\Microsoft\Windows CE Services"
Private Const INSTALLED_DIR As String = "InstalledDir"
Private Const CEAPPMGR_EXE_FILE As String = "CEAPPMGR.EXE"
Private Const CEAPPMGR_INI_FILE As String = "<application name>.ini"
Private Const APP_SUBDIR As String = "\<application name>"
Private TEMP_PATH As String = Environment.SystemDirectory &
"\TEMP\<application name>"

Public Sub New()
MyBase.New()
AddHandler BeforeInstall, AddressOf
CustomInstaller_BeforeInstall
AddHandler AfterInstall, AddressOf
CustomInstaller_AfterInstall
AddHandler BeforeUninstall, AddressOf
CustomInstaller_BeforeUninstall
End Sub

Private Function GetAppInstallDirectory() As String
' Get the ActiveSync install directory
Dim keyActiveSync As RegistryKey =
Registry.LocalMachine.OpenSubKey(ACTIVESYNC_INSTAL L_PATH)
If keyActiveSync Is Nothing Then
` Throw New Exception("ActiveSync is not installed.")
End If
' Build the target directory path under the ActiveSync
folder
Dim activeSyncPath As String =
CType(keyActiveSync.GetValue(INSTALLED_DIR), String)
Dim installPath As String = activeSyncPath & APP_SUBDIR
keyActiveSync.Close()
Return installPath
End Function

Private Sub CustomInstaller_BeforeInstall(ByVal sender As Object,
ByVal e As InstallEventArgs)
' Find the location where the application will be installed
Dim installPath As String = GetAppInstallDirectory()
' Create the target directory
Directory.CreateDirectory(installPath)
' Copy your application files to the directory
Dim installFile As String
For Each installFile In Directory.GetFiles(TEMP_PATH)
File.Copy(installFile, Path.Combine(installPath,
Path.GetFileName(installFile)), True)
Next
' Get the path to ceappmgr.exe
Dim keyAppMgr As RegistryKey =
Registry.LocalMachine.OpenSubKey(CEAPPMGR_PATH)
Dim appMgrPath As String =
CType(keyAppMgr.GetValue(Nothing), String)
keyAppMgr.Close()
' Run CeAppMgr.exe to install the files to the device
System.Diagnostics.Process.Start(appMgrPath, "\" &
"Path.Combine(installPath, CEAPPMGR_INI_FILE)" & "\")
End Sub

Private Sub CustomInstaller_AfterInstall(ByVal sender As Object,
ByVal e As InstallEventArgs)
'Delete the temp files
Dim tempFile As String
For Each tempFile In Directory.GetFiles(TEMP_PATH)
File.Delete(tempFile)
Next
End Sub

Private Sub CustomInstaller_BeforeUninstall(ByVal sender As Object,
ByVal e As InstallEventArgs)
' Find where the application is installed
Dim installPath As String = GetAppInstallDirectory()
' Delete the files
Dim appFile As String
For Each appFile In Directory.GetFiles(installPath)
File.Delete(appFile)
Next
' Delete the folder
Directory.Delete(installPath)
End Sub

End Class
Oct 5 '07 #1
0 2483

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jim Hubbard | last post: by
1 post views Thread by paritycheck | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.