I've logged into the visual studio as a different user while debugging the project encountered with error as:
"Windows service start failure"
But when I run with my own credentials working fine. I've tried by giving admin permissions to the particular user on the service but the result is same as below.
Can anyone help me on this?.
click here to see the issue
Ensure your service has a 'ServiceProcessInstaller' (right-click designer-surface of your service.cs and select 'Add Installer'), then change the account property for the service process installer to whatever suits your needs best (Network Service, Local System or Local Service). You may also need to specify the startup type of the service installer class.
To install it do the following steps:
Run Visual Studio Command Prompt as administrator.
Change the directory to the output directory of the service (where the executable file is located) - 'cd C:\directory'
Perform the following command 'installutil service_name.exe'
The service should then startup based on the startup type you specified. You may need to start it manually.
I am writing code that calls the IApplicationActivationManager interface to open a windows store app.
I get the error:
"[Name of App] can't run while File Explorer is running with Administrator privileges..."
It is essential that I launch my app as a non administrator. I also don't control the administrator context that the code that calls the .exe I will create uses. So, two questions:
Can I (by changing the project settings or something) debug as a non-administrator?
Can I force my exe to run as a non administrator? (when it's out in the wild)
C4ud3x helpfully points out that this can be added to the app.manifest. This is true, but unfortunately it will still run as administrator if the invoker lets it (it is in fact the default value). It also looks like asInvoker is the lowest value.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
edit:
fine I accept the only answer to the first question is don't run visual studios as admin. Thanks for all your help with that.
In your project-explorer expand 'properties' and open your 'app.manifest'.
You can add this line there:
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
'AsInvoker' means the application is started with the permission-level from the user whos logged in.
This line should already be auto-generated and commented out in your manifest.
Edit:
Aaah, wait. You need to run as a non-admin while DEBUGGING??? Dont know how the permissions behave in debugging-mode.
I did a lot of searching on this error and was confused when every single thing related to this has to do with AD.
First off let me just say, that my program runs from within VS 2013 with no problems whatsoever, whether it be in debug or release.
However when I run my program after rebuilding my program from the release folder I get an error saying "a referral was returned from the server".
My program doesn't have anything to do with AD.
Is there anything else other than AD that can give me this error? Most of the things I read up on they were giving specific lines that were causing the error during runtime, mine does only when not running in VS.
Sorry if this is a stupid question.
Thank you.
This is probably because you have the UAC enabled and a local group policy called Only elevate executables that are signed and validated also enabled.
Go to the Group Policy Editor > Computer Configuration > Windows Settings > Security Settings > Local Policies > Security Options and set User Account Control: Only elevate executables that are signed and validated to Disabled.
I got this error when I changed the requestedPrivileges in the application manifest file. I changed the uiAccess to true on the requestExectionLevel node. Reverting this change solved my problem. Level of the requestedExecutionLevel was set to "highestAvailable".
My solution was to add a post-build event to sign the resulting .exe
Previously only the .dll was being signed
I have an update button within the windows form application.When the user clicks on the update button, the application checks the current version of the application with the version available in the server obtained from the webservice. If there is mismatch among versions,the application will download the new version from the path obtained from the webservice.
I am currently using two projects within the same solution
Main project where the application is running
Update project -Its purpose is used to delete the .exe file and download the new .exe file. (Update project is added as a reference of Main project)
The problem is when i try to delete the mainproject.exe through code in update project,it shows an exception saying "Unauthorized exception caught". Does anyone knows why this is happening?OR Does anyone have a better idea to use update function within the application??
This is the code that i am using for the deleting the file.
Unauthorized Exception in Windows Forms - C#
Edit:-
While i was debugging the application,iam able to delete the .exe file.But when i try to delete the application after installing in the desktop,again iam getting the exception message as "Access is denied".
In you update button, you start another small app as a separate process , in the small app, you can use the following code to kill your process, and then delete the original app.
try
{
Process [] proc Process.GetProcessesByName("YourAppName");
proc[0].Kill();
}
I found the solution why iam getting the "access is denied" exception in my application.
Since iam deleting a file inside the application through code i need to have the privilege of "Administrator".
One way is to make the user login manually as administrator.But that is not a better option.
Another way is to create an App Manifest file within your project and set the level as "administartor."
Creating App Manifest--> Right click on the project->Add new item-->Select App Manifest option from the right pane->Click ok
Open the manifest file and change the level to "requireAdministartor".
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
This will solve the issue while running the application,it will prompt user to run as administrator.
Hope this will be helpful to someone in future. :) Thank you guys for your support.
Is the application running and that's why it is unable to delete the executable? If so, you could rename the running executable and put the new version in its place. The new version will then be executed the next time the application is started.
I am facing a problem for running my website.
I have developed the website and when i hit F5 to view the results i am presented with this error
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
How can i solve this problem.
This error usually happens if you Map your application folder on Network Drive or open Solution file from UNC Path. somthing like this:
Invalid Example: \\my-server\my-project
Try to open your solution from direct path
Valid Example: C:\Project\MyProject
You can also make change to your privilege of App Pool Identity but it's not recommanded:
Web Server (IIS) > App Pool Identity > Advance Settings > Set Identity as Network Service
the one shot solution worked for me was to set the App Pool Identity(Advance Settings) to Network Service
Try to set "Load User Profile" value of your application pool to "True".
It worked for me.
For what its worth, I found that the AjaxControlKit.dll on the deployed server was blocked. To resolve this, I copied over the dll to a new folder then copied and pasted in the bin folder. I guess .net doesn't like a dll being copied over directly to the web folder
you can run the following command to Grant FullTrust to remote share:
C:\Windows\Microsoft.NET\Framework\v2.0.50727>caspol.exe -m -ag 1 -url
"file:////\yourcomputername\yoursharename*" FullTrust -exclusive on
Hope this helps.
I tried all of the solutions posted here and a number of other places and nothing worked for me. I had my project located on a network drive which worked until I tried to use the AjaxControlToolkit 2.0 in my project. Apparently, something about permissions on the network drive would not allow the controls in the toolkit to run. I moved my project back to my local hard drive and it all started working.
I had this problem as well but have not seen this particular solution mentioned anywhere.
After checking permissions for the IIS user, the user for Impersonation, and granting Full Trust to the application, and still getting the error, I installed Procmon.exe on the server running IIS and noticed that IIS was attempting to access some Framework64 files for the offending website. I inspected the application pool advanced settings and discovered that "enable 32-bit applications" was set to false. Changing this setting to true proved to be the correct action. Life is good.
I face the same problem, then I realised that I was running the solution from a remote folder. Copy the necessary file to the local folder will solve the issue. But make sure that your folder have the full permission
While all of the other answers on this page may be the cause of anyone's problem, the most common one is due to OS security changes in Windows Server 2012 and above. Any file downloaded from the internet is flagged as suspicious by Windows and needs to be manually unblocked before using it in IIS. So if you FTP your code, email it, or transfer it through a cloud provider, it will be flagged and blocked.
The best solution is to use the web publishing facilities built in to Visual Studio or transfer through a network share if you're on a domain, each of which avoid this problem. However, if you must copy your code to another server by one of the means I described above, you should zip everything prior to transfer so you are only left with a single file to unblock. If you unzip before you unblock, then each file will be blocked and multi-selection will not give you the option to unblock.
So finally... to unblock: Right click the file and select Properties. Right there on the first page near the bottom you'll see an Unblock button along with the warning that the file was downloaded from the internet!
If the dll is compiled using this option (Do not merge. Create a separate assembly for each page and control), please make sure the dll is up to date. I faced the error due to aspx file is new one, but dll still using old one.
I found a potential solution that worked on my system and did not require changing to Network Service.
Go to Application Pool -> Advanced Settings -> Process Model -> Load User Profile: True
Source of this answer.
The best way to resolve this issue is Run the Visual Studio as "Administator". Right click on the Visual Studio icon and select "Run as Administrator".
Once you open Visual Studio with Full admin rights, you will be able access the page without any issues.
I have had this error and it seems to be a generic error. As there are several answers to this issue, I am going to add mine. Republishing the website on the remote server seems to fix it for me.