3rd Party assembly slow to load
Asked Answered
S

3

8

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.

Sapotaceous answered 6/2, 2012 at 19:43 Comment(6)
Pause the debugger during that time and look at the call stack.Peloquin
Is it only slow when Visual Studio (or another debugger) is attached?Northeastwards
IS your app a .NET 4 application while the DLL is ".NET 2" ? Depending on some settings the CLR of .NET 4 might need to load the .NET 2 CLR (this is a new feature in .NET 4) ?Boride
I haven't attached a debugger yet. The machine I'm experiencing the issue on doesn't have Visual Studio on it (a web server). The application should be running .NET 3.5 but I'll double-check that.Sapotaceous
Use fuslogvwr.exe to find out if the dll load other DLL's.Missie
The ABCpdf DLL was built in .NET 4 from what I can see from ildasm. From my understanding (although I've never used it before), fuslogvw only displays logs for assembly binding exceptions correct? Everything is binding correctly eventually, it's just taking waaay to long.Sapotaceous
B
5

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:

Bobbee answered 6/2, 2012 at 19:56 Comment(1)
This appears to be the issue. I turned off the 'Check for publisher's certificate revocation' advanced option in Internet Options to verify and the issue went away. Ultimately we're going to open up our firewall enough to let the box hit crl.microsoft.com (the revocation list server) which should correct the issue going forward. Or maybe we'll use the code in the answer below just to disable it for this library, not sure yet. Anyway, thanks for the point in the right direction.Sapotaceous
B
3

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>
Bahuvrihi answered 6/2, 2012 at 20:10 Comment(0)
P
0

I had a very similar problem which was when using the Gecko engine it would take 45 seconds to create the first PDF. Once started it was ok.

The issue was being caused because our prod server had no outgoing connectivity. To fix it there is a group policy setting that can be changed to set the timeout to 1 second. See:

http://technet.microsoft.com/en-us/library/cc753863.aspx

for steps on how to do this.

Picaresque answered 19/3, 2014 at 22:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.