Solved

VB.net windows application ,Create installer exe , Access Denied

Posted on 2010-08-15
16
1,301 Views
Last Modified: 2013-11-27
Hi
i create a windows application using vb.net 2008 and i use local data base file with (sdf) extension
then i create an installer file(exe) after that i install the installer on another machine

it install successfully ,but when i run the application i receive that access is denied to the sdf file

i solve the problem by going manually to the sdf file --> right click-->properties-->permission
and i give full control
and it work
now how i can solve this problem because i don't want to go to each machine around the world and do that
:)
0
Comment
Question by:Kamal Khaleefa
  • 5
  • 3
  • 2
  • +1
16 Comments
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 33439744
Sounds like you are storing the database in a restricted location (My Programs?). If you put it in the AppData folder, which does not have the same permission problems. Plus the file path can be easily retrieved using My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData

Wayne
0
 
LVL 16

Author Comment

by:Kamal Khaleefa
ID: 33439779
when i install the EXE all files are stored in a folder called Dictionary on Program Files

how i can add the folder App_Data to the installer
Thanks
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 33439841
In the File System Editor, add the "User's Application Data Folder" special folder, then add your database to it.

As a rule, only put files that you do not need to manipulate in the Programs folder. Anything else can go in the AppData folder.

Wayne
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 33462234
Try inserting this block of code in your applications "AssemblyInfo.vb"

Imports System.Security.Permissions
<Assembly: FileIOPermission(SecurityAction.RequestMinimum, Read:="Path of your sdf file")>

Open in new window

0
 
LVL 16

Author Comment

by:Kamal Khaleefa
ID: 33606757
PagodNaUtak:
how i can set the path
0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 33608471
If your database is in the same location of your exe, then just put the name of your file. The default is the same location of your program.
see below...

'The database is similar to the path of the exe file.
Imports System.Security.Permissions  
<Assembly: FileIOPermission(SecurityAction.RequestMinimum, Read:="Database1.SDF")>

or

'The database is located in a folder inside within in the exe file location.
Imports System.Security.Permissions  
<Assembly: FileIOPermission(SecurityAction.RequestMinimum, Read:="\Database\Database1.sdf")>

Open in new window

0
 
LVL 16

Author Comment

by:Kamal Khaleefa
ID: 33611201
i got the following error
Error while trying to run project , could not load file or assembly.....

Exception from hresult 0x80070057 (E_InvalidArg

but when i remove the assembly line it works fine)
0
 
LVL 16

Author Comment

by:Kamal Khaleefa
ID: 33614155
also im facing another problem regarding the sdf file
when i try to install it on another machines it give me error that

sqlceme35.dll cant be load

and note that sql and sql compact is not installed on target machine
so how i can solve this in my deployment
0
 
LVL 13

Expert Comment

by:Corey2
ID: 33706737
To add special folders such as Users Application Data folder you have to RMB on the file system node and select the desired special folder

To make sure SQL CE gets installed before your application you have to set the pre-requisites by RMB on the Setup Project and selecting 'Properties' then click the Prerequisites and browse down to the correct version of SQL CE.

Pre-requisites are only enforced by the Setup.exe so if you run the msi directly they will not be checked or installed.  The best way to ensure the setup.exe is run by the end user is to utilize one of the self-installers to unzip the files and automatically execute the setup.exe.  I use winzip for that.
PreRequisites.png
SpecialFolders.png
0
 
LVL 13

Expert Comment

by:Corey2
ID: 33706746
BTW one of the reasons the file cannot be edited on some computers may be due to changes in how windows vista and 7 protect certain directories suchas Program Files.  No application is allowed to edit files in these directories without RMB>Run as Administrator.  This is why it is necessary to put files that the application needs to edit in an accessible location like User's Application Data Folder.  In XP this was not necessary.
0
 
LVL 16

Author Comment

by:Kamal Khaleefa
ID: 33708979
does the location of the application data folder differ in xp ,windows 7 or vista

how i can read the location
0
 
LVL 13

Accepted Solution

by:
Corey2 earned 500 total points
ID: 33709010
Yes it does.

In vb it is under My.Computer.FileSystem.SpecialDirectories

This will give you the <OS User or all User folder>Application Data\Company\Product\Version&GUID folder you can use IO.Path.GetDirectory(SpecialFldr) once to get the Product folder and twice to get the company folder.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now