473,395 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 2822

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jim Hubbard | last post by:
I have some C# code that is supposed to wrap the defrag APIs and I am trying to convert it to VB.Net (2003). But, I keep having problems. The C# code is relatively short, so I'll post it...
1
by: paritycheck | last post by:
Hi Guys, I'm stuck with a terribly persistant "Access to the path *** is denied" problem. I'm trying to upload a foile using the file control. The code checks if a file of the same name as...
8
by: SteveK | last post by:
I'm getting the error: "Cannot implicitly convert type 'MovesDBMigrate.MotionNameElementTypes' to 'int'" for this line of code: m_nameElementTableNames = "Tbl_NameCharacters"; Of course if...
0
by: sharpener | last post by:
I'm new to C# and to newsgroups, so please bear with a possibly foolish query. I'll try to be sensible. The results of /// <summary> ... </summary> etc. appear immediately in the Object...
3
by: | last post by:
This question references to KB articles: http://support.microsoft.com/default.aspx?scid=kb;EN-US;315158 http://support.microsoft.com/default.aspx?scid=kb;EN-US;317012 I'm running Advanced Server...
7
by: TLM | last post by:
I am trying to build a web application that will contain links to files on a users local computer. I am assuming that the files will be in a known location and can display in a browser window. ...
8
by: ajos | last post by:
hi frnds, im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception. to verify this error ive...
1
by: Stefan Pascal | last post by:
Hello. I have a very strange problem on my system with running C# applications from a longer than usual (>127 chars) path. I was able to reproduce the following 2 cases: 1. Socket s = new...
6
by: fyitang | last post by:
hi guys, here is the sample: string strFileFullName = ""; try { FileInfo currentFile = GetOneFile("some directory"); strFileFullName = currentFile.FullName; // do someting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.