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.
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.
I'm willing to help for any particular question.
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...
Check solution properties. Have you checked optimize code checkbox there? Try unchecking it and then compile and run.
来源:https://stackoverflow.com/questions/21610680/quartz-net-initializing-project