Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


fred guanzon
2014-12-04T16:19:08Z
The way I am using Visual Cron today is I create a console application in Visual Studio which generates an EXE that I can pass command line arguments to from within a VC execute task. Also, I schedule these jobs to run are particular times of the day.

My question is other than console applications and execute tasks from VC, are there any other ways to execute program classes to run?

I use dependency injection, so I would need to setup the context calls and add the IOC libraries DLLs to VC if I wanted to do a C# code execute task.

Is there any other way to do this other than console apps?

Here is an example of my code in a typical program.cs:

using(var kernel = new Context())
{
var runner = kernel.Get<IRunner>();
runner.Run();
}


Thanks.
Sponsor
Forum information
Support
2014-12-05T14:45:52Z
You can also use the .NET Assembly Task to reflect and execute public methods in your exe or dll.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
fred guanzon
2014-12-05T19:19:54Z
Originally Posted by: Support 

You can also use the .NET Assembly Task to reflect and execute public methods in your exe or dll.



So I setup a class library to wrap the code I want to call.

Then in VC I called the resulting dll in a .NET Assembly Task. However, when I run the dll's publicly exposed method that has my IOC wire up and references set to Copy Local = True I still can't run my assembly method.

Here is the error:

ExecuteProcess("D:\Program Files (x86)\VisualCron\\NETExecute40.exe" 104)->Execution error(s): Exception has been thrown by the target of an invocation. Could not load file or assembly 'NLog, Version=3.0.0.0, Culture=neutral, PublicKeyToken=xxx' or one of its dependencies. The system cannot find the file specified.
Exception in Task: ExecuteProcess("D:\Program Files (x86)\VisualCron\\NETExecute40.exe" 104)->Execution error(s): Exception has been thrown by the target of an invocation. Could not load file or assembly 'NLog, Version=3.0.0.0, Culture=neutral, PublicKeyToken=xxx' or one of its dependencies. The system cannot find the file specified.


NLog is once of the references I am copying into my class library but NETExecute40.exe can't see it from the folder where the program dll is actually running:

D:\Projects\Consoles\Harvester\Harvester.dll

How do i fix this issue? Do I need to add NLog.dll and xml to the VC program files folder or create a system path?
Thanks.
thomas
2014-12-08T09:33:11Z
I am hardly the best to answer this question, but here are my two cents:

In the Microsoft world you either place you dll's in the GAC, or you 'copy local'. Anything else will lead to tears and more tears. In you case it seems you are executing a method in an assembly, that itself references another assembly located in another folder. That won't work. At least it has never worked for me. I am sure Henrik or someone else at support knows a lot more than me about this.

GAC:
https://en.wikipedia.org...ki/Global_Assembly_Cache 


Thomas
Scroll to Top