views:

599

answers:

8

I deployed an ASP.NET web application last night and I when I woke up this morning it was very slow and would occasionally just throw a 'Service Unavailable' error.

I checked the Event Viewer and it was filled up with these errors:

An unhandled exception occurred and the process was terminated.

Exception: System.Runtime.Serialization.SerializationException

Message: Unable to find assembly 'MonoTorrent, Version=0.80.0.0, Culture=neutral, PublicKeyToken=null'

I'm puzzled as it was working perfectly when I deployed it (MonoTorrent is required to retrieve the number of seeders/leechers for a certain torrent off the tracker - this was working fine), but it's no longer working and whenever code that uses MonoTorrent gets involved, the worker process just crashes.

MonoTorrent.dll is in the /bin/ directory.


UPDATE 6/4/10: I compiled the MonoTorrent source code in with the rest of my web application, but it still crashes whenever it uses MonoTorrent. However, it now says that it is Unable to find assembly 'OpenPeer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Here, OpenPeer is the name of the web application's assembly.

+1  A: 

Try clearing the ASP.NET temp files. It's solved some odd issues before for me.

Otherwise, Fusion-logging may shed some light.

UPDATE: @Charlie - I'm not sure what to make of those logs...it looks like the failed log is from a different AppDomain. Notice the AppBase is set to "file:///c:/windows/system32/inetsrv/" and AppName is w3wp.exe.

I'm pretty sure the Event Viewer should show Application Id: LM/W3SVC/#/ROOT if it was the default AppDomain, too. At this point, all I've got is random guesses.

  1. I notice you're running x64...does MonoTorrent perhaps require x86?
  2. Have you double checked that the directory is an IIS application, and is configured for the correct version of ASP.NET?
  3. Is there some other application that uses MonoTorrent on this server? Maybe a WCF service or something? I'm not sure where the Serialization is happening....
  4. Try hooking the AssemblyResolve event and loading it manually.
  5. Can you repro on a development machine? If not, maybe it's a borked FX install. Uninstall and reinstall.
  6. Does restarting, recycling or stopping/starting the AppPool fix the issue temporarily, or cause the issue to appear?

You may want to type out your screenshot text too so you'll get some Google love....

Mark Brackett
No, clearing the ASP.NET files doesn't help.
Charlie Somerville
@Charlie - And Fusion logging shows?
Mark Brackett
Some fusion logs show success: http://pastebin.com/jWfuiWRD and others show failure, but don't give any reasons: http://pastebin.com/DMG4mJGW
Charlie Somerville
And yes I know that I'm running the webapp as the SYSTEM account, that was a brief experiment to see if it would fix anything, but it didn't.
Charlie Somerville
@Charlie - Are you running IIS7? Are you creating a separate AppDomain?
Mark Brackett
I'm using IIS6, and this web application is in its own AppDomain
Charlie Somerville
Also, both my dev machine and the server are running x64. This is the only application using MonoTorrent. I'll check the other stuff though.
Charlie Somerville
@Charlie - Are you developing with IIS locally? If bit, Cassini (the builtin VS web server) is x86.
Mark Brackett
@Mark Oh, really? In that case I'll look into the whole x86/x64 thing.
Charlie Somerville
When I switched ASP.NET to run as 32 bit, it all stops working and just displays 'Service Unavailable'. When I switch it back to x64, it starts serving the web app again, but it still crashes when MonoTorrent gets involved.
Charlie Somerville
hum, your fusion logs show that your PrivatePath is NULL when the error occurs. May this help : http://social.msdn.microsoft.com/Forums/en-US/clr/thread/46bfff1f-f0e9-4565-90a9-6f75d4080353.
JoeBilly
A: 

I try to give you some ideas - what I do if I was on your position.

First of all I take a long look of the MonoTorrent.dll before some days that you make your question, and I look it again today. I found and the function that load the dll. My first opinion is that something have to do with the permissions.

I hope that you have access to the server - right ?

My first steps is that:

Ensure that your monotorrent.dll actuall have the right permissions to the bin directory, for Read, and execute by your asp.net app. Some times the copy of one dll, did not get the directory permissions buts carriage out his own permissions. To check if your dll have different permissions from the rest, just right click and see Properties | Security, then go to bin directory and do the same, and compare the Security permissions. If they are different then apply again the Directory permissions and make sure that the dll inherited by the directory.

My second step

Download the ProcessMonitor from sysinternals

http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx

Run ProcessMonitor and try to recreate the error, stop it and analyse to see where and why the dll gets the denied permissions to run. With the ProcessMonitor you can even see if there is any dll that can not found !

I have check the MonoTorrent dlls and I do not found anything unusual. He have kerner32.dll calls, and use unsafe code to run, ok nothing so special about.

So if you do that 2 steps and give me some feedback, maybe I can go further. (if not solve by you and what you find)

Aristos
A: 

My guess that you have plenty of open but not closed connections. I mean the connections are not returned to the pool. It looks okay, when you start the application, but after some time there are only several sockets available in the pool and it goes slow. Another thing - non-closed connection may keep DLL in memory, not allowing to release the handler. Try to debug object destruction.

ILog
This has nothing to do with the question asked. The scenario you described is not what is occurring.
Peter Oehlert
If you are so sure then I must apologize. I had similar behavior when synchronized threads incorrectly.
ILog
+1  A: 

Here are some things you can try..

1.) Flush ASP.Net Temp directory. Restart IIS and recycle Application pool.

2.) Make sure your web-application is running in FULL-TRUST if it really needs FULL-TRUST.

3.) Take the Assembly, try to use it in other asp.net application and run the test application on a seperate server. This might help you diagnose the problem. Also try to run the test asp.net app on the same server but in seperate application pool.

4.) Make sure the IIS website of your application is running under the user account with necessary security priviliges. Try running the application under Administratotr as user.

EDIT-1

5.) Also check if the assembly version is the same as mentioned in web.config. If there's a version mismatch then you can do AssemblyBinding Redirection in web.config.

6.) Also try registaering the Assembly in GAC and see if it loads properly.

EDIT-2

7.) Try reconfigring ASP.NET support on the server or maybe framework runtime re-setup may help. This may not be a sure-shot solution but looking at the problem condition we may want to try various solutions.

8.) Make sure you're not missing any critical update of your windows server platform.

this. __curious_geek
I've already tried 1 and 2. I only have one server to work with here, but I tried removing the Application Pool and the Website and re-adding both. For 4, I've already tried running it as `LOCAL SYSTEM` which didn't help.
Charlie Somerville
5 might have something to do with it though, as MonoTorrent wasn't mentioned at all in `web.config`. I added it myself, but I didn't include any version number. I just put `<add assembly="MonoTorrent"/>` under the `<assemblies>` tag. Could this affect anything?
Charlie Somerville
Also, I can't do 6 as MonoTorrent.dll isn't strong named.
Charlie Somerville
For 6, You can do strong-naming on your own using sn.exe tool.
this. __curious_geek
A: 

I would advice to setup Regular maintanence probably once in a week at sunday night etc for following,

  1. Delete all temporary files
  2. Delete all ASP.NET IIS temporary files
  3. Restart Server

Problem is, ASP.NET web apps cause lot of temp files to be left in the disk, because of dynamic compilation of regex, seriliazation assemblies etc, such temp stuff never gets deleted, and more and more junk starts getting collected in temp locations, ASP.NET goes slower and slower, and a point comes in where disk as well as memory defragmentation reaches very high point, things start to fail.

No body likes to restart server once a week, but I remember we had no choice, in ASP.NET 1.1 we had stable system after restarting every day, in ASP.NET 2.0 onwards, we are good to have restarting scheduled at once a week.

Akash Kava
I think that is too much to restart the server and clear all temp etc, every week. I believe that you have memory leeks, or you make too many updates - so your system needs to make again and again the asp.net system, or other user of you create problematic aspx pages. My system run continues more than 40 days, pools never recycle, free memory is good, speed is super, everything is working super fast.
Aristos
A: 

I have found this problem and I have do all of thing as I can, such as clear temp file, restart server, delete and add reference and I also rebuild the solution. However I can't solving this problem. Finally I move my entity class (almost of them need to serialize) to new folder that I have added to the project and then this problem solved.

This method is work for me.

In The Pink
A: 

Is the server timezone different than your timezone? I've had this issue when deploying resource files, the compile time was in the future so they would fail to load.

Shawn Simon
The server timezone is the same, but it's one hour out of whack due to Daylight Savings (ughh) I moused over MonoTorrent.dll on the server and the creation time is before the server's current time though.
Charlie Somerville
A: 

I know it's simple but I had this problem once and itwas because I had a Web Application project which contains

    References

Folder and I just copied my files into a

    Bin

folder, in any .net web application in the Project Properties windows, a Reference Path tab is available which by default should nothing be include on it. check this option and also Build tab in Project Properties window which Output path be as the same as bin\

Nasser Hadjloo