Why only a part of pods in a deployment starts successfully? - asp.net

I am deploying a dotnet app to AKS (Azure Kubernetes Service).
I do not know why but only a part of pods runs as expected while other pods throw a runtime exception and fail. I think the kind of exception does not really matter but in fact it is "System.IO.FileNotFoundException: Could not load file or assembly ..." thrown at program startup time. The container image is okay and all assemblies are there and running pods prove that.
What are possible reasons of such behaviour?

Okay, so it was my mistake. One of assemblies was referenced with PrivateAssets="All" in a .csproj file so this dependency was not propagated and required DLL was not copied to the output directory during the build process.

Related

Running dotnetcore Console application in Service Fabric Guest Executable

I am trying to run a dotnetcore Console application in a ServiceFabric GuestExecutable Container. While I was adding this GuestExecutable service to my SF application, I cofigured as follows
Code Package Folder -> ..repos\NewDllGuestSF\CoreConsole\bin\Debug\netcoreapp2.0
Program -> CoreConsole.dll
Working Folder -> CodePackage
Here, I know I am trying to host this .dll file as my executable for the GuestExecutable service. This is what I am trying to do but could not somehow. When I tried the same with the treditional .NetFramework app and with an .exe executable, I am able to run it successfully on SF cluster. But I need to do is with dotnetcore application and of course with a dll executable.
So far I have tried is -
I can generate a dll as well as an exe while building my dotnetcore console application and use the generated .exe file in GuestExecutable. But here, I have to configure my console app to target multiple Frameworks as "netcoreapp2.0;net461", that is something I can not do for some reasons.
When I run my dotnetcore Console app with a dll executable in SF cluster, I faced the following error
Here if we see, the GuestExecutable service remains in healthy state but the application doesn't.
Can anyone please help me out on this, all I want to do is to host a .dll file as entry point in a GuestExecutable SF service.
As far as I understand you need to configure CodePackage in ServiceManifest.xml to run your .dll using external executable.
Here is the example how this could be done (please pay attention to IsExternalExecutable="true" attribute):
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost IsExternalExecutable="true">
<!-- We are using dotnet cli to launch our Service.dll -->
<Program>dotnet</Program>
<Arguments>Service.dll</Arguments>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</EntryPoint>
</CodePackage>
Hope it helps.

TeamCity using MSDEPLOY ERROR_FILE_IN_USE

I have an ASP.NET 4.6.1 application that I am trying to deploy to a remote web server using TeamCity and MSBuild. Below is the MSBuild build step within TeamCity.
When I run the build in TeamCity, it always fails on this build step with a FILE_IN_USE_ERROR. The DLLs that are being updated before the error are usually the same, but sometimes they are different.
[MSBuild output] Info: Updating file (MyApp\bin\roslyn\Microsoft.VisualBasic.Core.targets).
[10:35:23]
[MSBuild output] Info: Updating file (MyApp\bin\roslyn\System.AppContext.dll).
[10:35:23]
[MSBuild output] Info: Updating file (MyApp\bin\roslyn\System.Collections.Immutable.dll).
[10:35:23]
[MSBuild output] MSDEPLOY : error Code: ERROR_FILE_IN_USE [C:\BuildAgent\work\b89cd3dfa447b\MyApp\MyApp.csproj]
I've already read through many articles (here, here, here, and here) suggesting that I drop an app_offline.htm file before deploying so that the IIS can re-route traffic and the file locking issues will stop. I tried that and it doesn't work. I still get the file in use issues during this build step.
I've also read in plenty of other discussions that another solution is to stop the application pool, deploy the app updates, and start the application pool. This is not a realistic solution because the deployment usually lasts between 15 and 20 minutes. Plus, this doesn't allow me to show a nice message to any current users.
I've been reading about this for a while now and it seems like this is a common use case for deployment to an IIS web server. Shouldn't this just work without locking files? Does anybody know of any other solutions to this problem?
I would try by stopping app pool to see if that`s a root cause of the issue.
But I'm not sure why it fails on .csproj file, because usually you don`t deploy those on server. So either it fails on different file (that is actually in use by web application) or it fails during build, not deploy (than app-pool stop will have no affect).

Azure Deployment: Could not load file or assembly or one of its dependencies. The process cannot access the file because it is being used

I deployed my multi-tier application to azure. It was working perfectly, but now when I try to deploying it, it shows an error saying:
Could not load file or assembly 'MySomething.dll' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)
I checked other answers, but all of them dealing with IIS. Azure Web Apps IIS cannot be accessed directly. How can I resolve this?
As usual, this issue happened because of caching. Removing the bin/obj directories alongside the IIS Express cache folder fixed the issue.

Debugger does not hit breakpoints on assemblies

In a web application I can't debug an assembly, but I can debug some others.
I have a tool that build some assemblies on a network path using CSC (with /debug param) and at the end of the compilation assemblies and pdbs are copied in the local site bin folder; for example are build two assemblies:
webui.dll
webbiz.dll
I have a middle assembly webframework.dll used from webui and webbiz that shows some methods used from them.
The situation when I'm facing the issue is the following:
from an httphandler I call a method of webui.dll using Assembly.Load, here I can debug webui's methods
following the code I call a method of webframework, here I can debug its methods too
following the code I call a webframework method, that handle other assemblies calls; here from a delegate is called a webbiz method using Assembly.LoadFile...here I can debug webframework methods, but not webbiz
Here I'm totally confused, and I can't find a solution.
Some info:
the webapp is runnig under IIS not IIS express
all assemblies are compiled for the debug and pdbs are fresh and not corrupted
if I try to Step Into the webbiz method I see The application in in break mode and I must hit Continue execution
I'm using VS2015, with VS2013 was working fine (!)
it's an ASP .NET related issue, because if I try to reproduce the issue on a console application I can debug
if I put the webbiz assembly in a path different from bin I can debug!
The only way I found to solve the issue is to use Assembly.UnsafeLoadFrom instead of Assembly.LoadFile

Location of symbols for WCF remote debugging

This is more a 'why does this work this way' than a 'how do I make this work' sort of question.
I have a WCF web service I am debugging remotely. It is deployed to a staging server where the VS 2010 remote debugger is installed and running as a Windows service. The permissions are correct, I can attach to processes without any problem. The issue I ran into is I couldn't consistently get the symbols to load.
I have the WCF service deployed to C:\Webs\MyService, with assorted DLLs in C:\Webs\MyService\bin. It is set up as a separate site with its own app pool. What I found is even if I had the necessary .pdb file in the bin folder, Visual Studio wouldn't load any symbols when I attached to the w3wp.exe process from my local machine. What was happening is when IIS started and the worker process was spawned, my service DLL would get copied deep under the temp ASP.NET files directory, into something like C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\19f82539\e55fff8f\assembly\dl3\2926a261\f625d158_f62ecd01. I found that if I manually copied the .pdb file to this folder, then symbols would be loaded and I could do the debugging.
I'm wondering why the heck it works that way, and how I can avoid having to manually copy the symbol file to this other directory. What's worse is if I had to make changes and redeploy, the worker process wouldn't recognize them. I had to restart IIS which caused a different temp directory to be created, requiring me to copy the .pdb again.
I have a similar problem, with web applications. Apparently Microsoft are aware of this: http://go4answers.webhost4life.com/Example/remote-debugging-symbols-not-loaded-207525.aspx
Hopefully, they will release a fix soon.
There is also a suggestion by BrianR on a related question, Why are no Symbols loaded when remote debugging?, saying to create a folder with the debug files and on the remote server to point the environment variable _NT_SYMBOL_PATH to it.

Resources