System.AggregateException: Azure can't deploy website - c#

So i have been deploying my website for some days now, suddenly i get a weird error when i try to deploy my website. I do use GIT, so maybe something went wrong there. These errors are kinda hard for me to understand. So i hope someone here can help me.
When i deploy the website, this is the error visual studio returns:
Web deployment task failed. (Web Deploy cannot modify the file 'PraktijkOpdracht.dll' on the destination because it is locked by an external process. In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.)
And when i look into the temp file where the error get logged. I see this:
15-12-17 22:58:28
System.AggregateException: One or more errors occurred. ---> System.Exception: Publish failed due to build errors. Check the error list for more details.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass40_0.b__2()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.d__108.MoveNext()
---> (Inner Exception #0) System.Exception: Publish failed due to build errors. Check the error list for more details.<---

The key to it is "it is locked by an external process." This kind of error usually can happen when the serviceplan is small dimensioned.
At that time more than one deployment is trying to succeed - before the other could finish.
Best practice to resolve could be :
extend the serviceplan
ensure to use deployment slots(make use of
parallel deploy stages)

I've experienced this before as well. I restarted my Web App and was then able to publish. This seemed to be a transient error for us.

I faced the same issue and got resolved after selected the checkbox in settings (I selected Publish to Folder)
Delete all existing files prior to publish
Precompile during publishing
Exclude files from the App_Data folder
Thanks

Minimize the path of publish folder with project name
Ex:
E:\ABC Project\bin\Release\PublishOutput
Then publish the project.

I've experienced the same in both publishing to Azure and local IIS path in my devenv
it was in Visual Studio publishing Settings > File Publish Options and uncheck Precompile during publishing checkbox

I know this was posted quite awhile ago, but I experienced this same issue and for me the problem was trying to publish my website to a folder that required administrative rights. Moving to a folder that didn't require administrative rights fixed this for me. Maybe running VS in administrator mode would also help, but I haven't tested that yet. Hopefully this helps someone at some point.

My case may be rare but FWIW I had this error/problem and it was due to a recent change to my network password. I was using VPN and Visual Studio was publishing to \server\c$... and until I disconnected from that c$ share and reconnected w/my new credentials I kept getting this VS publish error.

Same issue.
Cause was a middle application causing certificate to fail validation, in my case it was 'Fiddler'.
Troubleshooting: in VS web project -> Publish window -> click the edit pencil and then the Connection menu item on the left -> Click the Validate Connection button --->>> this will show a 'DO_NOT_TRUST_FiddlerRoot' error when the Fiddler application is in capturing mode (make sure to click "Reject" here); turn off capturing mode and click the Validate Connection to see this is the issue.
I have not looked into pulling the debug cert off VS and adding it to the Fiddler app but manual seems to work fine for the work I am doing.

Related

System.AggregateException Error When Publishing Website in ASP.NET

I decided to publish the ASP.NET MVC project to test it locally using IIS Manager. Therefore, after opening the necessary windows features, I created a new folder in the C:\inetpub\ directory on IIS Manager:
In the Visual Studio IDE I right clicked on the solution and clicked "Publish..." and specified that the target was "Folder":
When I clicked the Next button, I specified in the next window that the "Target" location was the C.\inetpub\TechnologyArticle directory. Then when I clicked the "Publish..." in the Visual Studio IDE, I encountered an error that I did not receive in Debug mode:
System.AggregateException: One or more errors occurred.
---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed.
---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed.
---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed.
How can I solve this problem? Is the reason why I got this error in Release mode, which I did not receive in Debug mode, due to programming?
This error is not due to programming. The reason for this error is trying to publish the website in the C:\inetpub\ directory, which is made visible and/or created by a service that you have activated by "Turn Windows features on or off" to publish the ASP.NET website locally. The user has no right to modify the C:\inetpub\ directory. Therefore, the current user's right to modify the C:\inetpub\ directory must be declared manually in the Windows 10 operating system.
When the ASP.NET website is published, the project outputs (such as *.dll files, style files, scripts, Views) compiled in Release mode will be extracted to the target directory, so the user must have the right to write to the C:\inetpub directory.
To resolve this issue, follow the steps below:
Open the properties of the C:\inetpub folder (With the folder selected, use the ALT + ENTER shortcut).
Switch to the Security tab and click the Edit button.
Define "Full Control" right for current user and confirm settings by clicking OK button.
You repeat the publish procedure to publish your website.

Visual Studio Publishing throws System.AggregateException without details at main development-System

Visual Studio Error at Publishing
Hello,
this is my first Question on this board, but i got plenty of good answers from here recently so i hope somebody could help with this specific problem:
I want to realize .net core Applications running on a Raspberry pi 4 and everything works pretty fine except that my Visual Studio throws a strange Error everytime i try to Publish the dotnetcoreapp3.1 as Self-contained linux-arm.
The Error says further there would be more information in the output log-file, but i checked it and it just said the same undetermined Error:
22.04.2020 22:44:33
System.AggregateException: One or more errors occurred. ---> System.Exception: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.
--- End of inner exception stack trace ---
---> (Inner Exception #0) System.Exception: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. <---
System.Exception: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.
===================
I tried to publish the project at another device with Visual Studio and it worked fine, after that i deinstalled visual studio and reinstalled it, after this not working i tried to repair with still no effect.
I hope somebody has an Idea how i can fix this ^^
Sincerely yours
Solved it by deleting an old unavailable nuget-path

ASP.NET Core server throws "Object reference not set to an instance of an object" upon calling Run on WebHostBuilder

I have one Windows 7 machine that throws "Object reference not set to an instance of an object" when ASP.NET tries to start up. I have 2 other Windows 7 machines and a Windows 10 machine where this same code works fine. It would appear that something about that machine won't let ASP.NET startup, but I don't know why. I have tried turning off Windows firewall, turned off his anti-virus software, put files in a different folder in case of weird permissions issues, tried changing to non-SSL server, and nothing I can think of will fix this issue with this one machine. The worst part about this is that the error is happening inside the WebHostBuilder's Run function so I can't really see why it is doing it.
This computer cannot run ASP.NET Core no matter whether it is my project or a fresh ASP.NET Core .NET 4.52 project, so I know that it has nothing to do with my code. My guess is that I could reformat that Windows 7 machine and reinstall Windows 7 and it probably would work fine, but I really would like to know why it is failing instead. I am wary of going to production if a certain percentage of computers simply cannot run my software especially since I don't know how often this will happen.
Anyone have any ideas what I could try to resolve this? A null reference exception is so vague I am at a loss about where to go from here.
Stack trace for outer exception:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait(TimeSpan timeout)
at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.DisposeListeners(List1 listeners)
at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.CreateServer(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication1 application)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host, CancellationToken token, String shutdownMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host, CancellationToken token)
at DBA.Server.ServerAppService.b__1_0()
Stack trace for inner exception:
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener.d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.ListenerPrimary.d__19.MoveNext()
Sorry about stack trace formatting...
Edit 4: I have reformatted my question now that I know the machine in question fails even when none of my code is involved and I am running the standard ASP.NET Core project template.
ASP.NET Core running under the full .NET framework requires .NET 4.5.1+ to be installed. If you instead only have .NET 4.5 installed you will get the "Object reference not set to an instance of an object" error when calling the Run method on WebHostBuilder.

Windows, Start service System.InvalidOperationException: Cannot start service on computer '.' Access in Denied(Running as Admin)

I am trying to start service using the below code. This works fine for 99% machines but i get this issue on user machines. Any help to be able to reproduce this error or why this issue happens.
ServiceController sc = new ServiceController(name);
if (sc.Status == ServiceControllerStatus.Running ||
sc.Status == ServiceControllerStatus.StartPending)
{
sc.WaitForStatus(ServiceControllerStatus.Running);
Logger.Info("Service already running");
return true;
}
sc.Start();
Error I receive is
System.InvalidOperationException: Cannot start service on computer
'.'. ---> System.ComponentModel.Win32Exception: Access is denied
I am running with Administrator privileges
When creating the service I also run sc sdset command to make service start stop by non admin processes.
There is a whole thread about it in social msdn. The issue persisted for numerous users and it seems you do not have enough privileges to start the service, in which case you will have to change the service into Administrative account:
make sure that the service is set to Local Account by:
Rightclick on the property(in Services.msc panel).
select the Log on option
And then check again to see if it's working.
I am assuming you are trying to achieve a scenario similar to this, i.e., install a service and start it automatically.
Assuming you have made sure that you are really running as Administrator, i.e., the Admin command prompt or Run As Administrator.
Also, assuming you have restarted the machine to make sure that old version of your service is really removed, as you have tried multiple times to install / uninstall your service.
The error Access is denied essentially means that the user running it does not have access. Since you have said that you are running as Administrator, it is possibly that even Administrator does not have access to start the service. May be you are in a locked down environment (likely via Group Policy), where only the Domain Administrator is the "most powerful" !
The next step would be to investigate the permissions your service has. A useful tool for this is: SubInAcl
https://ss64.com/nt/subinacl.html
Display or modify Access Control Entries (ACEs) for file and folder Permissions, Ownership and Domain.
SubInAcl /service "your service name"
The above command is not easy to use ! You need to download it from the Microsoft web site.
Another useful tool is the SC command. This would normally be available by default.
Service Control - Create, Start, Stop, Query or Delete any Windows SERVICE.
SC sdshow "your service name"
would give details of the permission.
This would give you data which can help in further investigation.
You could also start / stop the service with this command. You can try with this to check whether you are getting the same exception when using this tool as well.
The following serverfault question gives some details about setting permission to a service
https://serverfault.com/questions/187302/how-do-i-grant-start-stop-restart-permissions-on-a-service-to-an-arbitrary-user
If you want to see the Stack trace from installutil you can use the /ShowcallStack option
https://learn.microsoft.com/en-us/dotnet/framework/tools/installutil-exe-installer-tool
/ShowCallStack
Outputs the call stack to the log file if an exception occurs at any point during installation.
This is not an answer, it is my further exploration of the question.
Here is the log
Running a transacted installation.
Beginning the Install phase of the installation.
See the contents of the log file for the
D:\devnet10\Flight\Flight.ServiceHost\bin\Debug\flight.servicehost.exe assembly's progress.
The file is located at D:\devnet10\Flight\Flight.ServiceHost\bin\Debug\flight.servicehost.InstallLog.
An exception occurred during the Install phase.
System.InvalidOperationException: An exception occurred in the OnAfterInstall event handler of Flight.ServiceHost.Installation.
at System.Configuration.Install.Installer.Install(IDictionary stateSaver)
at Flight.ServiceHost.Installation.Install(IDictionary stateSaver) in D:\devnet10\Flight\Flight.ServiceHost\Installation.cs:line 36
at System.Configuration.Install.Installer.Install(IDictionary stateSaver)
at System.Configuration.Install.AssemblyInstaller.Install(IDictionary savedState)
at System.Configuration.Install.Installer.Install(IDictionary stateSaver)
at System.Configuration.Install.TransactedInstaller.Install(IDictionary savedState)
The inner exception System.InvalidOperationException was thrown with the following error message: Cannot start service PreFlight on computer '.'..
at System.ServiceProcess.ServiceController.Start(String[] args)
at System.ServiceProcess.ServiceController.Start()
at Flight.ServiceHost.Installation.OnAfterInstall(IDictionary savedState) in D:\devnet10\Flight\Flight.ServiceHost\Installation.cs:line 49
at System.Configuration.Install.Installer.Install(IDictionary stateSaver)
The inner exception System.ComponentModel.Win32Exception was thrown with the following error message: Access is denied.
The Rollback phase of the installation is beginning.
See the contents of the log file for the D:\devnet10\Flight\Flight.ServiceHost\bin\Debug\flight.servicehost.exe assembly's progress.
The file is located at D:\devnet10\Flight\Flight.ServiceHost\bin\Debug\flight.servicehost.InstallLog.
The Rollback phase completed successfully.
The transacted install has completed.
[Update]
I should mention that I am running WIndows 10
I managed to create an installer using an installer project, which does work.
The issue by me was RunningAsLocalService in topshelf, hope this helps someone.

Error deploying to AWS through visual studio

My co-worker is able to deploy our projects to AWS Elastic beanstalk fine. However I have issues on both my work machine and my home laptop. Both computers have the same error in AWS window pane.
I get a pop up as follows:
Deployment of the website failed due to errors during build of the deployment archive,
check visual studio output window 'Build' and/ or 'Amazon Web Service' panes for more details.
Then in the amazon window pane I get a different error everytime I try to run the deployment.
Example 1:
...package build 'CopyPipelineFiles': error in 'C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets' at (1413,5): Copying file Web.config to obj\AmazonDev\TransformWebConfig\original\Web.config failed. Could not find file 'Web.config'.
Example 2:
...package build 'TransformXml': error in 'C:\Users\Andrew\colony\colony-website\Colony.Web\Colony.Web.csproj' at (840,5): Could not open Transform file: Could not find file 'C:\Users\Andrew\colony\colony-website\Colony.Model\Web.AmazonDev.config'.
Seems to be a different error each time -- I'm not sure how to even begin to look for any issues.
Jim Flangagan's comment is the answer: ReSharper 8.2 is causing this problem. To resolve either disable resharper ( Tools>Options>ReSharper>General>Suspend Now) or upgrade Resharper.

Categories

Resources