Hi There.

I'm fairly new to vb.net, and i've been battling with this for ages and ages. Up and till a point where i wanted to slit my wrists.

I scouted all over google, and i still couldn't find any solution. So i'm really hoping you guys can help me out here. I'd really appreciate it.

I've got a few files i need to include with my vb application in order to have it work sufficiently and without error. I've got an mdb database, a few text files and a few dll files.

Now, my first problem is, that when i build and run the application, everything works great; exactly as it should. But when i publish my vb application, run the setup file, and then run the app, i get the following error: System.Data.OleDb.OleDbException: Could not find file 'C:\Users\admin`\AppData\Local\Apps\2.0\RG2AM4KN.N3Q\1QVM5LL9.GOO\test..tion_9fa9db93dabd8b22_0001.0000_67986ff05357f122\database.mdb' Appart from the file not existing, why does my application install to the AppData directory?

Isn't there a way i can have my application installed to the C:\Program Files directory instead?

That's the main issue i want to be able to sort at the moment, with the help of you guys.

So please, if possible, i'd really appreciate it if someone can help me out here.

Thank you in advance

:S

Dani AI

Generated

You are hitting ClickOnce behavior, not a traditional MSI installer. When you use Publish, the app is installed per user into the ClickOnce cache under the user profile (that long Apps\2.0 path) and ClickOnce manages that location for you. There is no Program Files choice in this model; if you need a per‑machine install under Program Files you must build an MSI/EXE with a setup tool (e.g., VS setup project, WiX, Inno, etc.). Microsoft documents that ClickOnce stores and isolates apps in a per‑user cache and handles the physical installation for you. (learn.microsoft.com)

On the missing .mdb: is on the right track. In Project Properties > Publish > Application Files, mark your .mdb (and related files) as Data File so ClickOnce places them in the app’s Data Directory. Then reference the file via the ClickOnce data path instead of a hard‑coded folder. Example in VB:

Imports System.Deployment.Application
Imports System.IO
Imports System.Data.OleDb

Dim dataDir = If(ApplicationDeployment.IsNetworkDeployed,
                 ApplicationDeployment.CurrentDeployment.DataDirectory,
                 AppDomain.CurrentDomain.BaseDirectory)

Dim dbPath = Path.Combine(dataDir, "database.mdb")
Using cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath & ";Persist Security Info=False;")
    cn.Open()
End Using

ClickOnce also migrates the Data Directory between versions during updates, which keeps your data intact. (learn.microsoft.com)

One more heads‑up for and : even if you switch to an MSI and install the binaries under Program Files, do not put a writable Access database there. Standard users cannot write to Program Files under UAC; use per‑user AppData or a shared CommonAppData location for mutable data. (learn.microsoft.com)

Recommended Answers

All 5 Replies

what installer?>.Net Deployment and package?

what installer?>.Net Deployment and package?

Thank you for your reply Jx_Man.


It's not an installer as such, it's the setup.exe file of my application after i published it.

Then, when i double-click the setup file, the .NET framework says "Verifying Requirements. Please wait...".

But, overall, that's not the issue. When i click that setup file, it installs my application to the AppData directory, in which case I'd like my application to install in the Program Files directory as per default.

How am i able to change the install path of my project, so that when i publish my application, it should install my application to the C:\Program Files directory?

The default installing path is [program files folder]\[product name] if you create a setup with Net Deployment and package without change the default path.
You can see the path in DefaultLocation properties of Application Folder. you can set application installing path there.

If you find out how to change the default installation path let me know, I would like to install my app to the program files folder as well.

As for your datafile issue, I was experiencing the same issue until I did this.

This is Visual Basic 2008 Express Edition.

Goto: My Project
Goto: Publish
Click Application Files
Select all of your database files and files associated with it and change it to Data File.

Now publish your application and install it and see what happens.

Torn...

I myself, had had the same problem with this, after digging around, i discovered that the "setup.exe" is not a real setup file, all it does is copy all the files to the LocalData/AppData folder. I also found, that since the publish option is an option integrated into the compiler, there is no way to edit the script. I also found that there is a program called Inno s that you run the wizard and put in all the program information with links to the main exe and all files to include, and it builds an actual installer with all options including text to show before and after setup, as well as changing the instalation directory and so on.
Happy Programing.
~Matt

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.