Loading DLLs into .NET under Deadline

Hi Russell and all,

Sorry if this is documented somewhere, but is it possible to load my own .dlls into Deadline?

I’ve built a small DLL to access a Windows API that’s not part of .NET, and it loads and runs fine under ipy.exe. However, when I try to run it with ExecuteScript, I get the attached error dialog. I tried signing my assembly with a “strong name key file” but that didn’t change anything.

Note from the output that even under deadlinecommand ExecuteScript, I can load the dll and extract the class from it; it’s only when I try to call into the class that the error panel is invoked.

After trying what’s documented here, I also tried placing the DLL in a directory that’s already on the Python include path defined in the repository, and then not doing the sys.path.append; it didn’t make any difference.

If it makes any difference I’m under Deadline 4.x, Windows XP64, and compiled the DLL for .NET Framework 2.0.

Leo

Test Script

[code]import Deadline.Scripting
from Deadline.Scripting import *
from Deadline.Scripting.ScriptUtils import LogText
import os
import os.path
import sys

def main(*args):
LogText(“Entry; arguments are %s”%(’ '.join(args)))
if len(args) != 2:
LogText(“No good! Must get exactly two arguments, src and dst”)
return
import clr
LogText(“clr imported”)
sys.path.append(r"H:\directoryWithDllInIt")
LogText(“Directory appended to path”)
clr.AddReferenceToFile(“DotNetHelper.dll”)
LogText(“clr AddReference called”)
import DotNetHelper
LogText(“Assembly imported via python import”)
from DotNetHelper import MyClass
LogText(“Class name imported”)
LogText(“Trying to call with %s , dst %s”%(args[0],args[1]))
result = MyClass.Create(args[0],args[1])
LogText(“Called MyClass.Create, result was %r”%result)

[/code]
DOS Shell Session

C:\svn\leo.hourvitz\trunk>"c:\Program Files\Prime Focus\Deadline\bin\deadlinecommand.exe" ExecuteScript H:\leo.hourvitz\LocalDeadlineRepository\scripts\General\TestDotNetHelper.py c:\tmp\test.mov c:\tmp\test2.mov Entry; arguments are c:\tmp\test.mov c:\tmp\test2.mov clr imported clr AddReference called Assembly imported via python import Class name imported Trying to call with c:\tmp\test.mov , dst c:\tmp\hardLinkToTest2.mov ---Security dialog appears here ---- c:\svn\leo.hourvitz\trunk >
SecurityException.png

Hi Leo,

What platform does your dll target (ie: win32, x64, or “any cpu”)? It may not matter, because it sounds like your dll is imported fine, but it doesn’t hurt to ask.

I’m really not sure what would cause this error. We have tested with custom dlls and didn’t run into any problems, so we would probably need your dll (or even your visual studio project and source code) to debug further. If you’re willing to send this to us, you can zip it up and email it to support@thinkboxsoftware.com.

Cheers,

  • Ryan

Hi,

Sent you the VS project separately. Thanks for looking into this!

Leo

Thanks Leo! We’ll try to take a look soon and get back to you.

Cheers,

  • Ryan

Russell pointed out the problem: .NET will refuse to load assemblies from a network share if the host program (in this case, deadlinecommand.exe) is being run from a local install. We’ll have to install the DLL locally to enable this.

He pointed out a good reference:
http://blogs.msdn.com/b/shawnfa/archive/2003/06/20/57023.aspx