.net Application is slow on publish - c#

I've made a sqlite DB application (.net Winforms) which is working fine. When I'm debuging the application in VS 2010 it starts up in 2-3 seconds. Also when i copy it to my desktop it is starting in this time. But when I'm making a setup which is installing to Program Files or Program Files (x86) it takes up to 10 minutes to start my application. Also when I start it from C:\ root. When I run it as administrator, or i provide a manifest to force administrator it takes 2-3 seconds.
On start up, i check with a few if File.Exists statements, if all dll's and files are in my folder.
I also have a log writer, which is creating a log file in AppData folder.
So i don't think I have any code part where administator rights were required.
Probably it could be the "SQLite.Interop.dll" but I'm not sure about this.
Hope someone could help me. If the are other questions or code is needed please ask.
Thanks
Martin
EDIT
Tried the application on a networkdrive, tooks 5 seconds to start without administrator.
I found out, that if i delete the language.sqlite file from my application folder, my application says language file missing. But when i reinsert the file, it keeps loading and loading.
Next test: I have added ALL System Dll's that I'm using in my application.
http://fs2.directupload.net/images/150611/3suqkzeq.png
(I can't post imags..)
This way it is working BUT only on the VM on my PC it isn't...

Related

How to build a WPF app so everyone can install and use it

I am entangled in how to work so that after I finish building the wpf app, I can give it to another computer by downloading the app (for example, downloading the .exe file). I also tried it, but when I ran the .exe file, it only showed a popup cmd and then disappeared. Then I have pulish with self-contanied deployment mode. Here is an image of the following files when I published at bin\release:
Path: C:\Users\ASUS\Source\Repos\UserService\WpfApp1\bin\Release\netcoreapp3.0\publish
If I run the .exe file in a folder then run normally. But when I copy it to a deskop and run it is still the same (can't run).
I want to ask how can I help my app to be used by other computers. Thank you mn! Forget more, my app is using .net core 3.0 already.

Where can I store my config file using windows forms?

I'm fairly new to windows forms and I was recently tasked with creating a simple software which will be deployed by USB drives to other companies. I made this software so during first run I check for a config.xml file. If it doesn't exist, I will send the user to a form to configure their first time setup. Next time I run the program, it skips this step since the config.xml file is found with its values. The problem is when I debugged this, I found the config.xml file alongside the executable, however when I ran this on a different computer, it stored it into the appdata virtual store. I read up on this and found out it has to do with write permissions.
Is there any way I can get around this without prompting the user to do anything extra on their part such as run as administrator? I also plan on saving the resulting reports generated by the use of this program and was hoping I can have XML files which can be easily found within the application folder.
*Note, I am aware of the built-in settings system but this also stores into appdata and if the executable is moved to another directly, it loses sight of that config and wants to create another.
EDIT : Please be aware I am trying to AVOID writing to the AppData folder. The software is packaged with Visual Studio Installer - Setup Project. A msi file is created which stores the application in C:\Program Files (x86)\\. Inside this directory I have the executable, the exe.config file which is generated, and any DLLs needed. This is the folder I am trying to also store the config.xml file but due to some windows magic, the code thinks its storing it here but in reality it is being stored in the virtualStore folder located in AppData.
Have you thought of using the C:\ most computers have this unlocked. alternitively use Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
the AppData folder is stored in the username space and requires no permission. (just remember to create a folder for your program to avoid conflicts)
It is a known issue due to security concerns that write permissions are limited.
More can be learned here.
Since no one was able to answer this, I will post my solution. Instead of packaging the solution using Visual Studio Installer tools. I install the application by copying the resulting executable from the build. This version of the application has write permissions that would have not existed if the application was installed using the resulting .msi from the Installer tools.

Visual Studio Installer : How to run application if it already installed?

I have application on C# created in Visual Studio 2015. I added installer project and created installer of my application. My installer saves path to install directory of my app in registry.
Is it posible when run installer to check if app is currently istalled - run it, if not - run installation progress?
My purpose is: I need to create a CD disk with my app. When user inserts this cd disk at first time the installer is run. When user inserts this cd disk another time the installed app must run without install process.
Autoplay of inserted CDs is something that is frequently turned off (the security risk) so I wouldn't count on anything automatic happening.
The normal behavior of inserting a CD and "running" it for an installed product is that a maintenance/repair operation occurs. It's probably not a good idea to change this behavior. Also, if your installed product is broken in some way and goes into repair mode then the user will be asked to insert the CD to get the install repaired (such as installing deleted files) and again it wouldn't be a good idea if inserting the CD broke this behavior and decided to run your app instead (or at the same time).
So this isn't really an install question because it's about the design of the program you put on the CD that deals with all this when the user runs the CD. It will need to see if the product is already installed, and if it is then run the installed app, except that the user may have put the CD in because Windows asked them to for a repair, and I don't know how the program can detect that it was inserted for a repair. If the product isn't installed then you run your setup. This all code you'd need to write, dealing with the issues that people have raised.
There are many issues here, and also I've never seen a product that behaves like this, so that's something else that users don't expect. It's not a good idea, as everyone is saying, and you almost need to decide which features of Windows Installer you want to break, such as repair and maintenance.

How do I publish a .NET application with OneClick publish through Visual Studio 2015?

I've been trying to research this the last couple of days and it doesn't seem like there is very good support for beginners. All video tutorials I find don't answer the questions I'm asking.
What I want:
I have an application I've written with .NET 4.6.1 in Visual Studio 2015 and I want to distribute an .exe that automatically checks if there are updates. It seems like this is exactly what OneClick is intended to do.
Where I'm at right now:
I want to publish to a shared drive among multiple people. It seems like I put that file path in the "Publishing Folder Location" which produces Setup.exe, MyApp.application, publish.htm, and Application Files. When you go to publish.htm there is an install button that downloads Setup.exe.
Where I'm stuck:
When you download the Setup.exe file onto your local machine and try running it gives an error. The details say it wasn't able to find the MyApp.application file. It seems that file is responsible for knowing what version of MyApp is currently installed on the users machine so that it can be compared to the download location (in my case the shared drive) to see if updates are available.
What am I missing? Do I misunderstand the purpose of OneClick publishing? Shouldn't users be able to visit the publish.htm once to get an .exe and that .exe is used to launch my application and look for updates first? I really appreciate any insight on this topic!
PS I've read over all the MSDN documentation, but it isn't user friendly to beginners in my opinion. Or maybe I'm just slow : )
You understand it exactly right, but when a user navigates to the html page, it downloads multiple files. The .exe, the .application and other supporting files.
You are correct in assuming ClickOnce is what you want. What I've found is the .net dependencies are very particular when using click once. You have to make sure each machine has the correct version of the framework and then they can use the htm site.
What I prefer doing is distributing the .application file to the users machine and just letting them run that. It will check for updates on the server every time it is ran and copy all the necessary decencies to the users Local directory.
You have to direct the users to the .application-File.
That one is responible for versioning (Updating) and executing your Application.
If you execute the .exe it will look for the .application-file to find the infos about the version, which should be installed/downloaded.
NOTE
Not all Browsers (in case of internet/intranet-deployment) support ClickOnce. But there are extensions for almost every browser

UnauthorizedAccessException when running application from CLRProfiler

I have an application that I am attempting to profile with CLRProfiler, written in .NET 4.0 and WPF running on the .NET Framework 4 Client Profile. The application loads a data file shortly after startup, the location to which is in app.config (so it is not selected interactively when the program is running). When the application is launched from Visual Studio or Windows Explorer, everything works fine.
When launching the application from CLRProfiler, however, the application crashes with an UnauthorizedAccessException attempting to load the file.
Attempting to fix the issue, I gave Full Control permissions to said file to myself, Domain Users, and Everyone yet the issue continues. When monitoring Task Manager, the short-lived process shows up has having been launched under my user ID.
Does anyone know how to resolve this issue with CLRProfiler?
Ultimately, this turned out to be a combination of two problems:
Not running as administrator.
The data file referenced above had a path specified in a configuration file, but the path was relative. When CLRProfiler launched the application, the working directory remained that of the profiler instead of being switched to the application under analysis. Since I was running unprivileged, the failure to open the data file was actually manifested as an UnauthorizedException because the application did not have permissions to root around in the folder where the profiler was installed.
After correcting both of these (the first by running as administrator the second by changing the config file to use an absolute path), the issues disappeared.

Categories

Resources