Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CsScript loading DLL throws error
#2
To test, I created a .NET dll in Visual Studio, for 3 platforms: "x86", "x64" and "Any CPU".
Tried to load the dll with this macro. You see results.
Macro Macro2129
Code:
Copy      Help
;CsScript x.Load("$my qm$\test\ClassLibrary1\ClassLibrary1\bin\x86\Debug\ClassLibrary1.dll") ;;platform "x86", works on Win7 32 and 64 bit
CsScript x.Load("$my qm$\test\ClassLibrary1\ClassLibrary1\bin\x64\Debug\ClassLibrary1.dll") ;;platform "x64", error on Win7 32 and 64 bit: "An attempt was made to load a program with an incorrect format"
;CsScript x.Load("$my qm$\test\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll") ;;platform "Any CPU", works on Win7 32 and 64 bit
out x.Call("ClassLibrary1.Class1.Test")
Then tried to load indirectly. Results are similar.
Macro Macro2129
Code:
Copy      Help
CsScript x
;x.SetOptions("searchDirs=$my qm$\test\ClassLibrary1\ClassLibrary1\bin\x86\Debug[]references=ClassLibrary1.dll")
x.SetOptions("searchDirs=$my qm$\test\ClassLibrary1\ClassLibrary1\bin\x64\Debug[]references=ClassLibrary1.dll")
;x.SetOptions("searchDirs=$my qm$\test\ClassLibrary1\ClassLibrary1\bin\Debug[]references=ClassLibrary1.dll")
x.Exec("")

#ret
using System;
using ClassLibrary1;
public class A{static void Main(){Console.Write(ClassLibrary1.Class1.Test());}}
QM creates x86 assemblies. Can load x86 and "Any CPU" assemblies, directly and indirectly. Cannot load x64 assemblies. Same on Windows 32 and 64 bit.
QM works almost like C# script (http://csscript.net/). In this case the difference is that C# script is compiled for "Any CPU" platform. QM - for x86. It means that C# script on Windows 64 runs as x64 and therefore cannot load x86 assemblies. QM assemblies always run as x86 and always can load x86 assemblies, never x64.

When testing same assembly compiled for different platforms, restart QM, or it may use the already loaded assembly regardless what is specified.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)