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.


VCMSL
  •  VCMSL
  • No customer Topic Starter
2015-05-27T14:18:35Z
Error:
Quote:

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



Version Info:
Visual Cron Version Information
Visual Studio Version Information

Walkthrough of Recreating Issue:



Create a Basic Job and Task
Here I create a basic job and task. No triggers, nothing special.

The task is a .NET Code Execute
The task is a very basic .NET Code Execute with one parameter-less public static method.

Visual Studio: Create new class library
Here I create a new Class Library and I target the .NET Framework version 4.0

Basic code for class library
The entire class library consists of one public class called 'Class1' and one public parameter-less method that always returns a string of "Hello World"

Compiled .DLL
I hit F5 to build my project, and I go find it in the bin/debug directory of my solution. Compiled and ready for action.

UserPostedImage
UserPostedImage
I go find the compiled binary and add it using the "edit references" button next to the 'Language' dropdown in the Add/Edit Task dialog.

Now for the ERROR.

UserPostedImage
UserPostedImage
I add a using statement for my class library's namespace. I hit compile and get no error and I also run with no error.

Class Library code compiles
When I create a new instance of Class1 in my project, my code compiles. But when I go to run it...

Error when using custom Class Library
And I receive this error no matter what I do. I cant find a proper stack trace anywhere.



I have a lot of tasks that are .NET code execute could benefit from moving chunks of similar code off to their own library. However, I cant seem to get VisualCron's executor to find my assembly.
Sponsor
Forum information
Support
2015-05-27T14:21:40Z
Is it compiled for .NET 4?

If you want to use libraries I recommend the Assembly Execute Task. This Task is primary built for using System dll methods.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
VCMSL
  •  VCMSL
  • No customer Topic Starter
2015-05-27T14:45:28Z
Originally Posted by: Support 

Is it compiled for .NET 4?

If you want to use libraries I recommend the Assembly Execute Task. This Task is primary built for using System dll methods.



If I do that, I can no longer code inside VisualCron. I then have to open visual studio to make changes and then re-compile and re-upload my DLL every single time I want to make a change.

Yes my DLL is targeting .NET 4.0 if you look at the create new project screenshot I uploaded you will see the .NET version selector on '4'.

I want to move a bunch of common functionality into my DLL like database calls used by other .NET execute tasks and a nice logging utility I wrote that makes the .NET execute tasks output more readable and have time stamps.
Support
2015-05-27T15:30:07Z
Originally Posted by: VCMSL 

Originally Posted by: Support 

Is it compiled for .NET 4?

If you want to use libraries I recommend the Assembly Execute Task. This Task is primary built for using System dll methods.



If I do that, I can no longer code inside VisualCron. I then have to open visual studio to make changes and then re-compile and re-upload my DLL every single time I want to make a change.

Yes my DLL is targeting .NET 4.0 if you look at the create new project screenshot I uploaded you will see the .NET version selector on '4'.

I want to move a bunch of common functionality into my DLL like database calls used by other .NET execute tasks and a nice logging utility I wrote that makes the .NET execute tasks output more readable and have time stamps.



I have passwed this information to our developers and we will see what we can do here to fix it. Meanwhile, please use the Assembly execute Task.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
thomas
2015-05-27T20:24:45Z
I'll throw in my two cents here. Not to insult you, but I think you are choosing the wrong 'path'. In my opinion there are only two cases where you may consider choosing not to go for the assembly task when you code in .NET. The first case is if you have a type of problem that needs a solution that will not be needed again, and the method is really small (even then I would consider an assembly). The second case is if speed is critical, for example in a loop (loading assemblies can take from milliseconds to several seconds in VC).

The advantages of of using assemblies compared to the .NET tasks are loads, but I'll mention a few here:

1) You get access to third party libraries that you won't have in the .NET task
2) You have an easy way of keeping your libraries up to date through NuGet.
3)You can code 'the proper way' using classes, interfaces, repositories, dependency injection, unit testing. You name it.
4)It will be a lot easier for the next developer to inherit your code.
5)You can get the help from tools like for example Resharper to write better code.

And a million other reasons. The best part is that it's easier to deploy to your visual cron server, than copying and pasting code. You can just 'publish' you code to a particular folder on the server, and job done. If you should need to move the code (dll) further, to say C:\ on the server, you can create a VC job that copies the files.

Don't create loads of .NET tasks instead of an assembly. You will regret it.

Thomas
Scroll to Top