Using .NET dependencies with Iron.io IronWorker

238 views Asked by At

I'm brand new to Iron.io's IronWorker, and I'm attempting to interface with it via C#.NET. I have managed to get the sample on the site to work, which utilizes the System.Web.Script.Serialization library. However, I want to use Newtonsoft.Json library for serialization/deserialization. My .worker file (located in the \bin directory of a Visual Studio project) looks like this:

runtime 'mono'
exec 'Debug\hello.exe'
file 'Debug\Newtonsoft.Json.dll'

I'm fairly certain that Newtonsoft.Json is being loaded, because adding the 3rd line of file: 'Debug\Netwonsoft.Json.dll' fixed the error that said that Newtonsoft could not be found.

The error I'm receiving when attempting to run a task is the following (I removed any seemingly sensitive information):

{"code_id":"[CODE_ID]","code_name":"hello","created_at":"2014-11-
16T13:48:01Z","duration":2452,"end_time":"2014-11-16T13:48:06Z","id":"[ID]","msg":"Unhandled 
Exception: System.TypeLoadException: Could not load type
'System.Runtime.CompilerServices.ExtensionAttribute' from assembly
'Newtonsoft.Json'.\n  at HelloWorld.Main (System.String[] args) [0x00000] in <filename
unknown>:0 \n[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could
not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly
'Newtonsoft.Json'.\n","project_id":"[PROJECTID]","start_time":
"2014-11-16T13:48:04Z","timeout":3600,"updated_at":"2014-11-16T13:48:07Z","status"
:"error"}

In the course of tracking down the error: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'Newtonsoft.Json', I ran across a SO thread that suggested there might be a .NET framework mismatch between v4.0 and v4.5. I'm using v4.5, and I tried changing it to v4.0 with no luck (so this may not be the issue).

Can someone please point me in the right direction as to how to properly utilize a dependency, such as Newtonsoft.Json (so at least the sample on Iron.io will work)?

P.S. I've been toying with IronSharp as an API to assist with interfacing with Iron.io products (once I get past this dependency issue). But, I'm open to suggestions if there's anything better I should be checking out.

SOLUTION

@Featalion's answer below really helped, becuase he pointed me to the stack command, which I placed in like so:

runtime 'mono'
stack 'mono-3.6'
exec 'Debug\hello.exe'
file 'Debug\Netwonsoft.Json.dll'

I believe it resolved the error at hand, because the higher mono framework seems to handle the latest version of Newtwonsoft.Json.dll. I'll post here if I find otherwise.

Make note that as of 11/17/2014, it seems the highest stack version supported by IronWorker is 3.6 (even though 3.10 is available, details found here). Check the highest stable release from Iron.io at this link.

1

There are 1 answers

1
Featalion On BEST ANSWER

This is, possibly, related to mono version on the IronWorker service. I found related question on StackOverflow. Try to change the stack in your .worker file to mono-3.6 or mono-3.0. See all possible runtime environments on Iron.io's dev site. mono runtime is default, and it is alias for mono-2.10.