Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Disclaimer</strong>: I don't know Quartz.NET at all, although I spent some time struggling with ILMerge. When I finally understood its limitations... I stopped using it.</p> <p>ILMerge'd application tends to have problems with everything which contains the word "reflection". I can guess (I've never used Quartz.NET) that some classes are resolved using reflection and driven by configuration files.</p> <p>Class is not only identified by its name (with namespace) but also by assembly it is coming from (unfortunatelly it doesn't get displayed in exception message). So, let's assume you had (before ILMerging) two assemblies A (for you Application) and Q (for Quartz.NET). Assembly 'A' was referencing assembly 'Q' and was using a class 'Q:QClass' which was implementing 'Q:QIntf'. After merging, those classes became 'A:QClass' and 'A:QIntf' (they were moved from assembly Q to A) and all the references in code has been replaced to use those (completely) new classes/interfaces, so "A:QClass" is implementing "A:QIntf" now. But, it did not change any config files/embedded strings which may still reference "Q:QClass".</p> <p>So when application is reading those not-updated config files it still loads "Q:QClass" (why it CAN find it is a different question, maybe you left assembly 'Q' in current folder or maybe it is in GAC - see 1). Anyway, "Q:QClass" DOES NOT implement "A:QIntf", it still implements "Q:QIntf" even if they are binary identical - so you can't cast 'Q:QClass' to 'A:QIntf'.</p> <p>The not-ideal-but-working solution is to "embed" assemblies instead of "merging" them. I wrote a open-source tool which does it (embedding instead of merging) but it is not related to this question. So if you decide to embed just ask me.</p> <ol> <li>You can test it by removing (hiding, whatever works for you) every single instance of Q.dll on your PC. If I'm right, the exception should say now 'FileNotFound'.</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COI ended up not using ILMERGE, it just wouldn't work and seemed like it required a lot more work than the benefit of having just a file files less in deployment runs. I also tried embedding, loading the assemblies dynamically, which helped me understand a lot more of the behind the scenes stuff, but it just wouldn't work for the hell of it. I loaded the assemblies at the earliest point, but had lots of static classes accessing them and they needed them to be re-loaded, but even static constructor was too late, strangely. always failed. your answer had most background, so thanks!
      singulars
    2. COWhat do you mean by 'loading the assemblies at the earliest point'? I have successfully used the method Jeffrey Richter described on his blog (see my earlier comment). It was very straight forward and the only to watch for is, you need to ensure that your AssemblyResolve event is initialized before anything else, which in my case meant creating a new entry point that setup the AssemblyResolve event and then called the old entry point.
      singulars
    3. CO@RomanMittermayr: I'm also puzzled "earliest" point. Although static constructor is quite early, the earlies point is module initializer. Unfortunately, module initializer cannot be altered with C# but can be altered with some minor IL manipulation (see: https://github.com/Fody/ModuleInit). When you say "reloaded" I have a feeling that Quartz.NET is creating separate AppDomains. That might be, in fact, a problem if you can't access them and inject you AssemblyResolver into them. You can try https://libz.codeplex.com/ as well.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload