.NET Core, log4net problems and listening - log4net

I'm using lognet in my .net core 3.1 application to log information on SQLServer.
It works while I'm in VS 2022, but it doesn't work when once I deploy.
It write on file system, but it doesn't write on DB.
Connection string is the same.
User is the same.
So I would enable listening.
In my code I have this expression:
log4net.Util.LogLog.InternalDebugging = true;
And in VS2022 listening informations are reported in Output windows.
One I deploy, I would to enable listening on a file. I found this example
How to track down log4net problems
but it doesn't seem to work on .net core.
Can you help me? How to enable listening on .net core? Do you know about alternative solutions?
Thx

Related

Remote debug Azure web job with .NET 6 in Visual Studio 2022

I followed this tutorial to create a simple web job in Azure: https://learn.microsoft.com/en-us/azure/app-service/webjobs-sdk-get-started. The web job itself does its job, consumes the message in the queue and I see them appear in Application Insights.
However, I want to debug the function on my local machine by using the tools available in Visual Studio 2022.
I have published with following profile settings:
Next I've attached the debugger under het Hosting menu:
First thing I noticed is a message about no symbols being loaded when putting a breakpoint in the function:
When I add a message to my queue, it gets consumed by the web job but the breakpoint is never hit. I've been reading a lot of similar questions regarding a this issue but I'm not progressing any further.
In Azure Portal, I've enabled Remote debugging under Configuration > general settings
In Visual Studio 2022, I checked if the correct process is attached
Here I'm a bit confused thou, the connection target is connecting through port 4024, which is according to this document, the port for Visual Studio 2019. However, a connection target with port 4026 is not found.
What am I missing here? Am I forgetting another setting somewhere?
If have tried changing the stack setting .NET version from APS.NET V4.8 to NET 6 (LTS) but that didn't help.
Should the platform architecture match the architecture of my machine in order to get it to work? Or is this not linked in any way with the debugger?
Is there anything else that I should check or try? Because my hair is turning grey here :)
Apologies for the delay here!
It should be 4024 for both 32 and 64 bit.
See this Azure doc: Remote Debugger Ports on Microsoft Azure App Service
Typically, the error “The breakpoint will not currently be hit. No symbols have been loaded for this document.” -- This error message indicates we can start debug process and attach, but cannot set a breakpoint on any or some lines of code in the project.
Most, likely cause: Application is built without debug symbols or debug symbols are not available
Kindly try these steps:
Verify Debug Symbols are being used and published and in sync
Workaround the issue by disabling “Enable Just My Code” from the
Tools >> Options >> Debugging >> general menu in Visual Studio
Other things to narrow-down the issue:
Debug symbols must be available locally or deployed to the Azure App Service, and must match the local code you are trying to debug.
It is recommended to use Cloud Explorer over Server Explorer to
connect and debug which requires the Azure SDK.
You could optionally Manually Attach a Debugger to Azure Web Apps to troubleshoot this further or recommend this as a workaround.
(old blog, try similar steps)
Kindly verify the port (Visual Studio remote debugger port assignments ) required is open in the corporate firewall and on your local machine.
As a test, you may use tool like Wireshark/netmon, to see if the port successfully connects to the port (4024) needed by the process.

Page keeps loading forever

Im using IIS 8.5 on Windows Server 2012 R2 so I add my Web Api but when I try to view the site it stays in a loading state like this:
Do not show any message or error just stays loading, I think that i miss some configuration or feature in my IIS but I don't know which one.
Edit: I use .Net framework, it is a REST .net web api like this reference, the IIS have installed .Net versions 3.5 and 4.5, it's IIS not the express and the default IIS website runs fine.
I would really appreciate any help.
Try to reduce the timeout settings to a minimum level, say 10 seconds.
See if it throws a Timeout error.
Without much information from your side its hard to judge.
Perhaps it could be an external service you are trying to access(Web service) or a DB connection?
Please check if the application pool you assigned to your solutions runs under the correct version of .net framework and in integrated mode. I had similar issues when trying to run an mvc app in classic mode. Check this out.
EDIT 1 - Reconfiguring IIS
If problems persists then try the ASP.NET IIS Registration tool. Execute the followig command as administrator:
aspnet_regiis -i
At the end of this post the different locations for aspnet_regiis are described. You should select a .NET Framework version corresponding to that of your project, run aspnet_regiis and assign the proper application pool to your app.

Asp.Net Core 2.0 on Azure results in a 502.5

I have a small web app developed with Asp.Net Core 1.1 deployed on Azure and it works well. I just migrated the project to use Asp.Net Core 2.0 and tried to deploy it on Azure. The deployment went fine but when I open the site, I get a 502.5 error. When I check my Azure log stream, I get the following error:
This error occurs when a CGI application does not return a valid set
of HTTP headers, or when a proxy or gateway was unable to send the
request to a parent gateway. You may need to get a network trace or
contact the proxy server administrator, if it is not a CGI problem.
Useless to say that it works well on my development machine with the same code. Note that I'm also using Entity Framework Core 2.0 although I deactivated the database creation on Azure (to check if it was not the cause).
For information, the way I migrated from 1.1 to 2.0 is by changing the target framework settings to "netcoreapp2.0" and by using the NuGet package "Microsoft.AspNetCore.All". Just to be sure, I also deleted my publish profile and recreate one.
Is it possible that Asp.Net Core 2.0 is not yet available on Azure ? I'm fairly new to Asp.Net Core, so I don't know when new releases are made available on Azure.
EDIT
When I try to run my app with dot net CLI via the debug console as proposed by natemcmaster, I got the following issue:
Unhandled Exception: System.IO.FileLoadException: Could not load file
or assembly 'Microsoft.AspNetCore.Hosting.Abstractions,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
The located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)
I downloaded the DLL on my desktop and check the version with Dot Net Peak and indeed, the DLL is 1.1.2, although I created the project with Visual Studio and directly publish it, so is it an issue with Visual Studio ? Or Nuget ?
the issue was actually coming from the fact that, at first, my web app was using .net core 1.1, which deploys all the DLL in the "wwwroot" folder of the web application. However, with asp.net core 2.0, it does not do that anymore as the DLL are picked up from a global store. However, as Visual Studio does not clean the destination folder before a publish, I ended up with a situation where the 1.1 DLL were in my wwwroot, so the web site was picking up these ones instead of the 2.0 ones in the store folder.
This is explained in more details here: https://github.com/Azure/app-service-announcements-discussions/issues/2#issuecomment-313816550
Others have explained the reason why this is happening. I'd like to provide another – arguably easier – solution to the problem.
Just change the settings so that you remove files that are already on Azure – see below:
Check for log files either in the portal or by remotely accessing D:\home\LogFiles.
Sometimes, the logs won't indicate what is going wrong. Another good way to investigate further is to try launching your ASP.NET Core app from the Debug Console. If you are missing a shared framework version or there is another startup error, this will be more visible from the Debug Console.
Go to
https://(your web site name here).scm.azurewebsites.net/DebugConsole/
Your site will be in D:\home\site\wwwroot. You can launch it by executing:
cd D:\home\site\wwwroot
dotnet MyWebApp.dll
If you app still fails to launch, make sure that D:\home\site\wwwroot\web.config is available and configured to use ASP.NET Core Module. https://learn.microsoft.com/en-us/aspnet/core/hosting/aspnet-core-module
In my case, It was caused by having a space in the Project Name.
I can readily add a space, publish => 502.5.
Remove space, publish => good to go.
Hard to believe but I am duplicating it readily with above.
Also using "Remove Additional Files at Destination" per #Sam's Answer
See https://github.com/Azure/app-service-announcements/issues/14
"The rollout is expected to complete by Friday June 30th."
In my case the issue occurred because AppService at that time supported 2.0.0-preview2-006497 but I had 2.0.0-preview3-006890 installed which was used on build.
So I added global.json to use preview 2 SDK and it worked then
I don't know if this could help someone one day but in my case, I was using :
-Microsoft.AspNetCore.All 2.0.5
Downdrage to Microsoft.AspNetCore.All 2.0.3 resolve my problem
This happens when your version of ASP.NET Core cannot be matched on the server.
The simplest solution is to change your settings to deploy the app as self-contained, so it doesn't matter if Azure can match the framework version. Also, delete the files already on Azure, so you don't have issues when upgrading, as explained by #Sam.

ServiceStack selfhosted performance on Raspberry

I have a C# console application with a self hosted ServiceStack server (based on AppSelfHostBase).
It has both REST API (get and post) and a "standard" html/javascript website.
If i run the code under Windows, it works great, but if i run using RaspberryPI, it is slow and never got a response.
Any ideas?
Thanks
Leonardo Zambonelli
If you're using ServiceStack on Mono on Raspberry PI I'd recommend converting your project to .NET Core which will provide an instant performance improvement.
All .NET Core Apps are Console Apps and you can checkout the ServiceStack .NET Core Apps for examples of ServiceStack Apps running on .NET Core.
Thanks mythz!
I'm not worried about performance at the moment, but the main problem is that is not working at all! I don't need high performance because it's just a Rest Service that is used by one user(app) at a time.
The application is quite big, and converting to .net seems to be quite hard (we use a lot of serial port communication, and other stuff that are not present in .net core)
Added: just a quick note. On a Virtual Linux machine it works fine, so the problem seems to be only on Mono on Raspberry. If someone has any suggestion ( a part converting the project) it would be useful.
Thanks
Leo

SignalR 0.5.3 and IIS 7.5

I have an application already deployed on a couple of customers utilizing signalr for communication. It works on windows 2003 server with IIS 6.0 with the mappings configuration, also works on win 7 and iis express. But for windows 2008 R2 with IIS 7.5 the hubs file although it's served, the signalr.hub with the list of server methods is NOT included in the script therefore clients can't connect to the hub.
Help is appreciated!!!
Ok, so here is what I found. We have a setup project that installs our product. I haven't looked into the process in detail but what it does is: creates a website under iis default, then assigns an app-pool that runs with Frw 4.0 and I think it also registers the framework at some point of the process. So, for some reason the javascript hub file was being generated without the actual definition of the hub. After so many teaks I decided to remove the website from iis and added it back manually and it got fixed. So, I don't know what setting was impeding signalr to initiate the hub but that was how I solved it.
Thanks

Resources