4

I am new to Quartz.Net and I have been following this tutorial to do my first Job. I followed every step and started from zero 3 times but I cannot make this to work. When I run the project on Visual Studio I get this message from the cmd:

Failed: Could not load file or assembly: 'HelloWorldDotNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

On Visual Studio output I get:

'HelloWorldQuartzDotNet.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. no configuration section found - suppressing logging output 'HelloWorldQuartzDotNet.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Remoting\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Remoting.dll' A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

I cannot understand what that mscorlib.dll is... I tried to search for that and I couldn't get anywhere. I am using the recent version of Quartz.Net 2.2.1 on Windows 8.

mantal
  • 1,093
  • 1
  • 20
  • 38
João Martins
  • 1,026
  • 2
  • 14
  • 35

3 Answers3

2

After downloading project and following step-by-step tutorial, I found problem with it, after a some time spent in debugger. So tutorial will guide you from client side perspective on using Quartz.NET, and there are no problems with it. Code is building fine, and everything works like a charm. Problem is on server side of project, and error you are getting is sent from service that is running Quartz.NET server implementation. Line throwing an exception is:

// Line 40 | ScheduleJob.cs
var schedule = schd.ScheduleJob(job, trigger);

What's happening here is that scheduler is informed about new job called WriteHelloToConsole for HelloWorldJob class implementing IJob interface. Once server receives this information, he tries to find that dll within his application domain (here comes problem). However, there are no HelloWorldJob in Quartz.NET server domain (folder), since you have downloaded it directly from the SourceForge server. That is reason why you are getting could not load file or assembly.

Solution is simple, yet not recommended, but for this tutorial sufficient. You just need to copy/paste HelloWorldQuartzDotNet.exe into the Quart.NET service folder and start/stop service from Windows Services. Once you do this, it will load HelloWorldJob class (and also other classes from HelloWorldQuartzDotNet.exe) in Quartz.NET server application domain.

Recommended solution for other project, specially for production. Create separate DLL for each of your, so one DLL for IJob class and separate DLL for Quartz.NET. Add references to the client and copy/paste DLLs to service. This way you will have everything decoupled and you will get maintainable solution.

If you need more about how .NET application domain works, you can get it from this link.


Note: Best way to start/learn/play with Quartz .NET is with their documentation. There is a handy tutorial on how to setup everything from small console app to the windows service. I have implemented it several times, only using documentation.

Quartz.NET

I'm willing to help for any particular question.

TheLittleHawk
  • 628
  • 3
  • 22
0

Mscorlib.dll is a class library which contains core functions of the .NET framework and it is clearly letting you know that it cannot find HelloWorldDotNet assembly by throwing FileNotFoundException...

Make sure that your HelloWorldDotNet assembly builds fine. Check what is your StartUp project in Visual Studio and make sure it is correct and has a reference to this assembly. Check all the references in your project...

Dean Kuga
  • 11,878
  • 8
  • 54
  • 108
  • I tried to add mscorlib as reference and I get the following message: "A reference to mscorlib could not be added. This component is already automatically referenced by the build system". Although I had the target framework to 4.5, I also changed that to 4.0 and still don't work. – João Martins Feb 06 '14 at 18:39
  • @JoãoMartins - this has nothing to do with mscorlib. this has to d with your application that you did not deploy with the solution called "HelloWorldDotNot" – Ahmed ilyas Feb 06 '14 at 18:42
  • @Ahmedilyas I have all the possible names called "HelloWorldQuartzDotNet". I don't know what more I can do – João Martins Feb 06 '14 at 19:39
  • @JoãoMartins - are you using Quartz.NET from NuGet or did you reference the quartz assembly manually? Can we have some sample code? – cvbarros Feb 06 '14 at 21:42
  • @cvbarros I am using references from NuGet. I am just trying to get that simple tutorial in the original post to work. Some guys are reporting in the comments section of the tutorial the same error that I have but nobody answers. Although in the comments section there are people talking about this: " It is necessary that your job dll is available in the folder. How you get it there is your choice. Also note that the service needs to be restarted after the job dll has been placed there." but I don't understand what job dll are they talking about or in what folder it should be... – João Martins Feb 07 '14 at 14:30
0

Check solution properties. Have you checked optimize code checkbox there? Try unchecking it and then compile and run.

Amit
  • 882
  • 6
  • 13