Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

3rd Party assembly slow to load

I have a command-line process that creates a PDF file from an HTML file using ABCpdf. I'm trying to upgrade from v5 (very old, no longer supported) to v8 but after installing ABCpdf 8 and updating my application to use the new DLL, I've noticed that the process which used to take less than a second to convert now takes 20+ seconds.

I've added some trace calls in the code and it appears that the point where the program attempts to reference an object from the ABCpdf 8 DLL is where things pause for a good long while. Once the code gets past that point it runs as fast as ever.

The question I have is: What could cause the CLR to slow down so much when attempting to reference a 3rd party library? I've verified that the ABCpdf 8 DLL is in the GAC as well as the same directory as the executable.

Thanks in advance.

like image 509
AlphaKilo Avatar asked Feb 06 '12 19:02

AlphaKilo


2 Answers

Out on a limb, let me guess:

You are running this on a server without (outgoing) internet connectivity.

The component is strongnamed and signed with a cryptographic key. The certificate is being checked (the revocation list is checked whether the certificate is still valid and trusted). This times out due the absense of an internet connection.

If you want to confirm this, attach a debugger (WinDbg?) and confirm the following stacktrace on any of the threads:

0e82c1b4 7c822124 ntdll!KiFastSystemCallRet
0e82c1b8 77e6bad8 ntdll!NtWaitForSingleObject+0xc
0e82c228 73ca64ec kernel32!WaitForSingleObjectEx+0xac
0e82c254 73ca6742 cryptnet!CryptRetrieveObjectByUrlWithTimeout+0x12f

There has been a Service Pack release for Windows server editions that broke this by defaulting to have the check enabled. You can disable it using a registry setting.

See ASP.NET Hang: Authenticode signed assemblies:

Oh, that page didn't (clearly) link to the solution:

  • <generatePublisherEvidence> Element
  • FIX: A .NET Framework 2.0 managed application that has an Authenticode signature takes longer than usual to start
like image 82
sehe Avatar answered Nov 02 '22 08:11

sehe


If it is the cryptograpic issue, you can solve it by using the followng app.config entry. But afaik this is only an issue if the computer has dns, but no other internet connection available(firewall).

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
  <generatePublisherEvidence enabled="false"/>
</runtime>  
</configuration>
like image 27
Manuel Avatar answered Nov 02 '22 08:11

Manuel