7

I running a C# MVC website written on C# for quite long time. Recently, I've noticed this log message in my logger data:

System.IO.IOException: The network name cannot be found.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileSystemEnumerableIterator`1.CommonInit()
   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
   at System.IO.Directory.EnumerateFiles(String path)
   at System.Web.WebPages.Deployment.WebPagesDeployment.AppRootContainsWebPagesFile(String path)
   at System.Web.WebPages.Deployment.PreApplicationStartCode.OnChanged(String key, Object value, CacheItemRemovedReason reason)
   at System.Web.Caching.CacheEntry.CallCacheItemRemovedCallback(CacheItemRemovedCallback callback, CacheItemRemovedReason reason)

I also know:

  1. This exception is thrown from the ASP.global_asax file.
  2. This happen for one time in few weeks. But, when it's happen, I see this exception for few times in my logger (delay of a second between each exception).

As you can see, nothing in this call-stack is in my code. Therefore, I don't know how to repro this or solve this.

How do you recommend me to solve this? Any tip will be helpful.

Mohan Perera
  • 370
  • 1
  • 4
  • 15
No1Lives4Ever
  • 6,430
  • 19
  • 77
  • 140
  • Looks like something in a config file is pointing to a network path. SMB paths are prone to sometimes be unavailable for a few seconds. Grep everything for "//". – usr Apr 12 '16 at 09:19
  • Check your code for places where you do "throw". odds are someone did a "throw exception" which hoses your stack trace. replace with "throw" alone and that should at least get you a full stack trace to work with the next time it happens. Info on "throw" vs "throw ex" found in this answer: https://stackoverflow.com/questions/2728640/what-does-throw-by-itself-do – user7396598 Jan 26 '18 at 21:24
  • Could you be able to share your global.asax code? – Nagaraj Raveendran Jan 26 '18 at 21:26
  • 2
    Maybe backup software is locking files. Or the remote server does a reboot, making it unavailable for a minute or so. – VDWWD Jan 27 '18 at 09:50
  • @user7396598 In my case, this isn't the issue. It seems to be a process internal to ASP.Net which is throwing the error, hence the lack of relevant stack trace. But we still need to figure out why it's happening and how we can prevent it. – Josh Noe Jan 28 '18 at 22:00
  • And I agree with VDWWD, VMware backups can cause IO errors. – smoore4 Feb 02 '18 at 21:19

2 Answers2

3

Looking at the source code, this exception is triggered by the framework itself.

It tries to enumerate all files in the HttpRuntime.AppDomainAppPath. It looks like this path is not always available in your scenario, which seems a little strange. Where are you hosting your files?

I suggest you to log the value of HttpRuntime.AppDomainAppPath and search from there. I think it will be a rather unusual value...

Manuel Allenspach
  • 12,467
  • 14
  • 54
  • 76
  • 1
    We're hosting the app on an Azure App service. I guess it's possibly some internal issue with their VMs. – Josh Noe Feb 01 '18 at 22:08
  • Or the Azure site is "going to sleep" like this question: https://stackoverflow.com/questions/33789895/how-to-prevent-an-azure-website-from-going-to-sleep – smoore4 Feb 02 '18 at 21:17
  • @smoore4 It doesn't seem like this could cause the filepath to be unavailable? – Josh Noe Feb 03 '18 at 18:43
-4

the network is probably down you can fix this by simply adding a catch to catch this exception and display a message that the host of the network name is down and it should fix the network problem before attempting whatever it is you are doing again.