How to debug the application after deployed in IIs? - c#

Hai All,
I'm developing the application using .net 2008 and Oracle 10g as database. I have deployed the application in IIS, now when two users get logged into the same applicaion, same page at a time getting error as
"*Connection must be open for this operation.Cannot access a disposed object.object name: 'Oracle.DataAccess.Client.OralceConnection'.Connection must be open for this operation"*
Plz give a solution to solve this multiuser issue..
Thanks in Advance!!!!

The easiest way to look into what's happening on IIS is to deploy a debug build, connect to the machine the server is on, and run the CLR debugger. Of course, this is only really practical in a staging rather than live scenario (or you have dozens or even thousands of people hitting the breakpoint, and of course the whole thing freezes up while you are stepping through).
This case sounds a bit like you might have a connection object statically scoped, or otherwise shared between threads, rather than created as needed on each thread of execution. It's the sort of thing sometimes seen if someone tries to manually pool connection objects (which is pointless, indeed counter-productive, as the underlying connector objects are pooled for you).

Related

Application never finishes starting in debug, possibly Redis?

I have an asp.net web application that is hosted in Azure and using a Redis cache to manage session storage. Every so often, the application will hang when debugging in localhost for no apparent reason.
Essentially, in Visual Studio, I'll hit the start button. A new web browser window will open like it's about to open the page, but instead it will simply load and load forever. If I try pausing the debug session, it seems to always land somewhere within the Redis dll, but I can't be sure where exactly.
No matter how many times I kill all processes and restart Visual Studio, this behavior will continue until I restart my computer. What could possibly be causing this?
Redis was never designed to run on Windows, the version they make available is really only for testing purposes.
If you have issues with it hanging, it could be that it is miss-configured. This question on serverfault may help.

Losing session after file changed / uploaded

I am currently having a strange issue with sessions, I've worked with MVC for quite a while and never had this in previous versions. Currently making a new system using MVC5 for the first time, all is well. Sessions are being set with no issues, however, if I modify a cshtml file in VS my session is killed.
Also I have a file upload feature which works, but when you upload a file and then navigate to another page the session is gone again. This is working locally and also on a Windows Server box we use for sandboxing.
Has something changed with the new versions of MVC regarding sessions? I've never had this before. I've got it set to use in-proc sessions, never normally needed to change anything but I have for the sake of things used cookieless, used cookies etc as options. Nothing seems to work.
If anyone has an idea that would be great.
It is interesting that you haven't observed this earlier - as always when you update the contents of your web site, IIS could recompile declarative resources causing the restart of the app pool which effectively removes all session data stored in memory.
A solution would be to switch to other, persistent session storages, sql is possibly the easiest to configure. You just need a sql server where you run the script that creates the session database:
http://support.microsoft.com/kb/317604
Another option would be to use the State Server:
http://msdn.microsoft.com/en-us/library/ms178586.aspx
The performance of the State Server is usually better than the SQl Server as the data is not persisted onto the disk. However, since the state server is a separate process, your application server won't loose sessions even when the app pool restarts.

How to debug a C# service that stops for no reason on production server

We have implemented a pair of services in C# that send and receive faxes. These services have been running flawlessly for several years on several servers - until last week.
One of our clients upgraded to Windows Server 2012. We installed the services and all hellbroke loose.
Basically, one of the services appears to work for several minutes, and then, for some unknown reason - goes to the OnStop method. So someone, or something - is stopping it, but I don't know what it is.
How could I go about debugging this? I am new to C# and this is not my code.
Any help would be appreciated.
Is interesting the fact you are sending and receiving faxes: It colud be related to some Session 0 Insolation introduced with windows server 2008/2012, that could cause problem in graphic related services.
If you have some chanches to run the server on a developement machine, using a Windows7/8 box and a SYSTEM user, you can probably reproduce the problem.
If it only stops on the production server, it is reasonable that there is something different about the production server than your development server/workstation.
It is probably unlikely that you're allowed to hook a debugger into something on the production server, but the best way to handle this is just to log the he** out of the code.
You should introduce enough logging to figure out:
Where it stops
Why it stops (my money is on an exception)
The state of the application at that time (related to the crash)
This will probably have to be done in iterations, unless you go all out to begin with.
Services and logging go hand in hand, so just implement it.

CPU usage goes high in Asp.Net MVC application while longer process run by other utility

I have one application which is developed in ASP .NET MVC 3 which using a SQL server database.
Apart from this, I have one console application which calls an external web service and update the same database with the information and business rules. (Basically we iterate the records from Web service and process the business rule and update the same database), we have configured the console application with Windows scheduler to process it periodically.
The problem is, when my Console application runs periodically, it uses the 100% CPU usage (because we're getting more than 2000 records from web service), and because of that my current MVC application is gets haging OR sometime works very very slow because both application are configured on same windows server.
Could anybody please do let me know that How would I resolve this problem where I want both the things on same server because I have central database used by both application.
Thanks in advance.
You haven't given any detail that anyone can really provide resolution, so I'll simply suggest how I would approach it.
First, I would review the database schema with a DBA to make sure there aren't things like table locks (or if there are, come up with strategies to compensate for them). I would then use the SQL Server profiler to see where (or if) there are any bottle necks in SQL server while these things are running. I would then profile the console application to make sure it's not doing something it doesn't need to be doing. I might even consider profiling the web site to see if there's anything in there that might be contributing to slowness.
After that, I would figure out how to get rid of the Console application and work its functionality into the site. Spawning another application on a given web request is not scalable. More than a couple of those come in at once and you've got the potential to bog the server down very easily.

C#: How to graciously manage errors on the application DataBase?

I have a C# application that uses a localhost DB (MySQL).
Now, when I create the executable I´m assuming that the receptor computer MUST have the exact DB with the the same name and tables, also, must have running WAMP or XAMPP.
If one of this conditions is not accomplished the program will crash horribly, with the errors of Windows/C#.
I could put exceptions for every case, but I´m fearful that I would hide other errors putting exceptions for everything!
With production software, how do you manage this? With exceptions? Writing a manual for the user? etc?
During bootstrapping, I recommend check to see if a DB Connection can be created (in my case, SQL Server), given the database connection string defined in an app.config. Initially, you should do some version checking on the database. If the database can't be found, attempt to create it. if i'ts out of date, attempt to upgrade it. If this process fails, then your database engine instance isn't installed or is unresponsive. For my application case, I exit the program, as there's nothing else to do if the DB can't be accessed.
Once past this point, I generally assume that the DB connection is active.

Categories

Resources