views:

285

answers:

2

Hi,

My C#.NET application is running much slower when the exe is located on the network.

And I'm talking about everything, even the graphical dispay is slower. For example: when a form is already loaded, if I unplug my network cable and minimize and maximize the window, it takes a very long time to redraw itself (whether the cable is plugged or not).

I'm using framework .NET 3.5 SP1.

Any idea on the cause?

My hypothesis so far:

  • I'm missing some options when building the app?
  • my corporate antivirus checks more stuff because the exe is on the network
  • the cache of Windows XP SP3 doesn't work the same way when the exe is on the network
  • the server is a Novell server: maybe this does change something ?

Thanks for your help!

Leo

+4  A: 

Perhaps because the CLR needs to go across the network to read any new assemblies, etc?

You would probably have better luck using a one-click installer, where the application is installed on the local machine but updates can be downloaded from a centralized server.

Justin Ethier
Is there any way to check that? Because even when my cable is unplugged, the form does load eventually.I will look into the installer thing but I really need to improve performance even without one-click installs.
leo
+2  A: 

I'm surprised that unplugging makes a difference. I would expect some difference running from a share, though - you get a different security mode, i.e. not full trust. In full trust most of the internal security is simply skipped. Without full trust it works a lot harder. "Fusion" (assembly resolution and loading) also will have to work harder, but this shouldn't be a problem when repeating operations you've already done once in that session (i.e. when the dlls have loaded).

Have you considered deploying (still to a network share) as ClickOnce (.application)? This should then copy locally automatically and run with a better trust model (and no network performance impact).

Marc Gravell
I'm sorry I think I was unclear: unplugged or plugged, the result is the same. Based on your answer, I ask myself: is there a way to run the app in full trust mode even if it remains on the share?I don't know what "Fusion" and "ClickOnce" are but I will certainly look into it, thanks.
leo
@leo - actually, depending on which *exact* version of the framework you are using (including SP level), it can run as full trust if it is a **mapped** share (F: etc), but not as a UNC share (\\server\share). Alternatively, use `caspol.exe` to mark the share as trusted.
Marc Gravell
It indeed was a problem of security.As explained here:http://blogs.msdn.com/shawnfa/archive/2008/05/12/fulltrust-on-the-localintranet.aspxFullTrust is only granted to the DLLs in the same folder as the exe. I have subdirectories for localization. Granting FullTrust with caspol makes a huge difference.It's not an acceptable solution for me though, so I have to find a way to either grant FullTrust to those subfolder at runtime, or packaging these DLLs in the same folder as the exe.Anyways thanks to you I found the cause of the slowness, so thanks for that!
leo
The only viable way I found was to use .NET framework 4.0 in which you can set the FullTrust for DLLs loaded from the network, in the config file: `<runtime> <loadFromRemoteSources enabled="true"/> </runtime>`This is impossible in .NET 3.5 SP1.ClickOnce was a possible solution but not good for my project since it wasn't embedding a lot of DLLs that I load by Reflexion.
leo