Search code examples
c#.netsigned-assembly

Why are signed assemblies slow to load?


I encountered a strange problem this week that I can't explain: I switched my application to use the signed version of some third party assemblies (Xceed Grid and some of their other components) and the application start time went into the toilet. Each time the application loaded a signed assembly, it took 30 seconds to load. Application start went from 5 seconds to over 90 seconds. What the heck is going on here?!

Some other info:

  • This is a WinForms app running under .NET 3.5 SP1.
  • The computer had no internet connection (on purpose, for security).

Solution

  • Have a look at these links:

    • https://web.archive.org/web/20120812062059/http://blogs.technet.com/b/markrussinovich/archive/2009/05/26/3244913.aspx - The Case of the Slow Keynote Demo (Mark Russinovich’s Blog)

      Confident now that the cause of the startup delay was due to .NET seeing that Stockviewer.exe was signed and then checking to see if the signing certificate had been revoked, I entered Web searches looking for a way to make .NET to skip the check, since I knew that the keynote machines probably wouldn’t be connected to the Internet during the actual keynote. After a couple of minutes of reading through articles by others with similar experiences, I found this KB article ...

      ... checking of assembly digital signatures: create a configuration file in the executable’s directory with the same name as the executable except with “.config” appended

      <?xml version="1.0" encoding="utf-8"?>
      <configuration>
            <runtime>
                    <generatePublisherEvidence enabled="false"/>
            </runtime>
      </configuration>
      

    They might help. It could be that the config on your system means that the .NET framework is doing a lot of extra work to verify the assembly. If this is the case, then you can configure it to not be so picky.