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.
Related
I have an application written in C# using VisualStudio 2015 and I want to publish it (eg give an exe or installer to somebody to use it on its PC). From VisualStudio there is possibility to click "publish" in solution explorer. The result files are:
-Application files (File folder)
-project.application (Application manifest)
-setup.exe (Application)
As far as I know "manifest" file should be some metadata, but I can execute that file and it gives me an installer (the same as setup.exe). After installing it runs an application (just like setup.exe). It makes me confused - what exactly project.application is? Can I delete it and use only setup.exe? What is the correct way of publishing an app? One last thing: why does the installer run installation on first execution and run an application on any other? I would expect to run installation any time (just like other software).
Thanks
It sounds like a ClickOnce application. See the following link for more information:
ClickOnce security and deployment
In a nutshell:
The installer copies the files to the users AppData and then runs the application.
There are also other options such as checking for updates from a network location or web address. Then when you run the application it checks for updates and uses the manifest to do an incremental update of the application files.
I have created a code, which compares XML files on the client side (in PC) with the XML file located on the FTP server; where once it detects that client is running older version of the program, it will download the latest build (so that user has always up to date program).
Here is the trick. Due to the fact, that I am overwriting files at run-time, I had to create an external console application which is being called from the main app if user wants to update. This way, first console application is executed and afterwards main app is closed, so that no files are locked by the system (application's .exe file would otherwise be locked and we could not replace it with the new one).
This process runs perfectly, if it is being installed somewhere else other than under the system folder (by that I mean e.g. C:\Program Files\ drive). If user has decided to install main application there, then suddenly my app crashes as it does not have admin privileges.
I am using Install Shield LE when disbursing this app, and users that are using this program are not administrators (which means that I go to every computer and type admin password when I/users install this program).
Is there a way, how to execute my updated console application with admin rights, or how to define via Install Shield that once this app has been executed, I always want it to be executed as admin?
Hope that my explanation has not been confusing. I am more than happy to share additional details if necessary, as I need to figure out how to solve this thing.
I imagine you don't have an AD configuration as Emmanuel suggest, because in this case you would push the updates without any problems and would not have to design an automatic updater.
I don't know if InstallShield has something like this, but Advanced Installer has the support to install a dedicated updater that runs as a service, thus it has all the permissions required to install an application under Program Files.
Of course this means you need to replace your updater with the one from Advanced Installer and also that the initial installation of the application on the end user machines will still require admin credentials. (future installs can install silently, without the user's intervention)
You'll need to add the following line to your app manifest:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Documentation on the msdn is here.
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...
I created a setup project in VS2008. This setup copy some folders/files to the program files folder. Also, it adds some windows environment variables.
During the instalation, I am requested to confirm something in a UAC dialog.
This works fine, and all files are copied.
The problem begins when my program is running and I have to modify the a file´s content.
An exception is thrown, saying that I have no permission. Also, if I try to do the same operation in Windows Explorer => same problem.
My question is:
If I have the permission to install my software in program files folder, shouldn´t I be able to write in this folder as well?
Well, it seems that this is a general permission problem. By default normal users (and applications) cannot write to %PROGRAMFILES%. There are folders specially provided for application data storage such as ApplicationData
The reason the setup does install into program files is because this default behaviour of the Windows Installer. Check this link for more info on the Windows Installer and clickonce setup
I have an application which I deploy using a setup program in Visual Studio 2010 on Windows 7. The program deploys and runs fine on Windows 7 and XP, but when I deploy it on a Windows 8 system I get errors about access to a configuration file.
The program gets installed in c:\Program Files (x86)[Company Name][App Name]\ and the file being referenced is a temp file with a name that looks machine generated by Windows GetTempFile, e.g. x4q0toqw.tmp. which does not exist in this folder and then there is a reference to the exe config file (myapp.exe.config, which does exist)
If I build and run the code on the Windows 8 system it installs and runs fine, I don't get the error, but then if I deploy the Window 8 compiled app on Windows 7 I get the same errors about access to the configuration file. Both machines are 64-bit but generate a 32-bit application.
I don't plan on releasing two binaries. Can anyone tell me what is going on? I'm in the process of trying to setup JIT debugging to that I can attach to the exe when it throws exceptions, since debugging it natively doesn't help me as I don't get the exceptions.
This is on two different machines, but I login to the same domain as the same user on both, and am an administrator.
Maybe your application is rewriting your app config during the load and this will cause the system to question the access grants... if so, may be you can change the properties of your application (the installed one) to have administrator rights... This will give your application to automatically have the right to programatically edit the app config.
OR... you can just forget about the app config rewriting and put everything in the default app config script. but this will expose your application database security...
I had the same error. This is because the temp file gets created in C:\Program Files (x86)\[Company Name]\[App Name] folder and the normal Users (PC Name\Users) don't have the permission to modify this folder. As soon as I added modify permission, it started working fine.
I resolved a very similar problem in Visual Studio 2010 on Win 7 by elevating the account privileges that my service ran under. See step 9 here:
Set the Account property to LocalSystem.
When my serviceProcessInstaller1 ran under LocalService account I got an error like yours. But changing the account to LocalSystem fixed this issue. My installed service was then able to write to its C:\Program Files (x86)\[Company Name]\[App Name]\[App Name].exe.Config file. This was even though the install for Just me checkbox was checked when I ran the service's setup program.
Bear in mind the remarks here though:
The LocalSystem value defines a highly privileged account, but most
services do not require such an elevated privilege level.