C# windows service crash - c#

I have a windows service which process text files using a file watcher, which is working fine (thanks to your previous help).
My other part of the project is a portal, where I access the processed data, see a log of all activities (which I'm using listview with an update panel and timer).
Now I found that whenever I access the messages or the log, my service crashes, as the page try to load the messages (over 70000 records for 3 days only).
It might be due to the big number of records my portal is trying to read while the service is writing a new records at the same time.
I'm using Entity Framework and my catch is throwing this error "Error: An error occurred while updating the entries. See the inner exception for details"
My service and portal are updating the same log table on the DB (but I don't think this is the reason).
any idea?

Related

Logging and troubleshooting HTTP 502s (Request Timeouts) within Azure App Service

We had an issue this week where a non-performant SQL query caused an app to start sending 502's as the time it took to run the query passed the Azure App Service request timeout setting (which seems to NOT be user definable)
I'm trying to find a way to detect and alert on these issues. I've gone thru the microsoft documentation but only find recommendations like "scale out" - If I look at Application Insights it doesn't seem to log the 502 since, from the app's perspective, the script ran successfully. Is there a way to log there instances with some context to fix non-performant scripts before a user calls in about a 502? The only option I see is to NOT use the built in load balancing/app gateway features of Azure App Service and roll a separate load balancer/gateway to have more control over it..

Log4Net offline DB Support

I am developing an asp.net web application and want to log my exceptions into SQL DB. For this I am using Log4Net AdoNetAppender to log info into SQL DB, now the problem occurs when the DB goes offline. Log4Net doesn't persist the log messages. So all messages get lost while the DB was offline, is there any way to retain the messages until the DB comes online and then log all the messages to DB once it become available. Although by using reconnectonerror value="True" it starts logging again when DB is available but all intermediate messages while DB was offline are not logged.
Or there exist any other approach to log exceptions in Db with offline support.
There is nothing with helps you out of the box with this. You can always log to a file (keep the last week or so) and the database. If for some reason there is a gab in the logging you can fallback on the file.
If you want the behavior you describe you can always implement your own appender. Let is inherrit from the adonetappender and add your failover code. However keep in mind that you do not want to create an appender which eat all your memory...

IIS 7.5 site displays page cannot be displayed

Yesterday I was setting up a new site the same way I always do and when I went to test it I was at first getting error 503 and the application pool would stop for the site when that page was displayed.
Today its no longer displaying the 503 error and is now displaying page cannot be displayed. Also the application pool is no longer stopping.
I checked the Event Viewer and its getting the following error whenever I try to get onto the site:
A process serving application pool 'CP4_ICEGROUP' suffered a fatal communication error with the Windows Process Activation Service. The process id was '8136'. The data field contains the error number.
I have many sites that I have set up previous to this and they work fine. I have tried creating a different site since but that also wont work.
I have installed debugdbg and created a dump file and read it with the debugdbg analysis but was unable to find what is causing the problem.
Any help will be greatly appreciated.
Set up the user login for the database for the site wrongly!

SQL Dependency causing errors in SQL Server

We have a C# web application that is using SQL dependency to expire cached query data. Although everything is working okay we are seeing a lot of errors being generated particularly in our production environment.
The first error messages is this:
Service Broker needs to access the master key in the database
'SubscriberManager'. Error code:32. The master key has to exist and
the service master key encryption is required.
It shows up in both the server event log and the SQL server log files. I believe the actual content of the messages something of a red herring as I have created a database master key.
I have also tried
Recreating both the service master key and the database master key.
Made sure the database owner is sa.
Made sure the user account has permissions to create services, queues, procedures and subscribe
query notifications
Made sure the broker is enabled
I have seen other people with similar errors whilst researching the issue but the error code almost always seems to be 25 or 26 not 32. I have been unable to find anything that tells me what these error codes mean so I'm not sure of the significance.
At the same time this happens we also sometimes get an error from .net saying the following:
System.InvalidOperationException: When using SqlDependency without
providing an options value, SqlDependency.Start() must be called for
each server that is being executed against
The applications call SqlDependency.Start in the Application_Start
event though.
These errors are strangely intermittent though, they do not happen every time a particular page is hit or even every time a notification is created or triggered. I have tried attaching SQL Profiler and monitoring the broker events and seen the notifications created an triggered without any problems.
Finally I am seeing a lot of errors like this:
The query notification dialog on conversation handle
'{2FA2445B-1667-E311-943C-02C798B618C6}.' closed due to the following
error: '-8490Cannot
find the remote service
'SqlQueryNotificationService-7303d251-1eb2-4f3a-9e08-d5d17c28b6cf'
because it does not exist.'.
I understand that a certain number of these are normal due to the way that SqlDependency.Stop doesn't clean everything up in the database that we are seeing thousands of these on one of our production servers.
What is frustrating as we have been using SQL notifications for several years now without issue so something must have changed in either our application or the server setups to cause this but at this point I have no idea what.
The applications are .net 4.0 MVC and WCF running on Windows 2012 servers calling SQL 2012 servers also running on Windows 2012.
According to Microsoft if the SQL Server is short on resources particularly memory it can cause theses errors to be generated.

Crystal Reports massive generator

I have problems connecting to the report's database. In my log I see that an exception is thrown : "Log on failed".
This is what I do: I am using a service that needs to massive generate reports. When opening the report with Crystal Reports everything is ok, but when using this service, it throws an exception saying log on failed.
I tried Verify Database from the menu in Crystal Reports but it says everything is up to date. My service uses a batch for massive generating reports on the server. I am unable to connect to the database.
I think that there are some security issues when trying to connect to the database like this. I can't do any debug, except logging my steps.
Please help !
Have you tried a "canned" Crystal Reports batch scheduler like:
http://www.reportrunner.com
http://www.christainsteven.com

Categories