Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another CsScript dll issue
#1
Hi -

I'm having trouble loading a C# script that uses a .NET v4.0 or v4.5 dll. Is there a way to make this load?

I've just taken the working code from a previous post and added a
Code:
Copy      Help
using System.Threading.Tasks;
statement. This example doesn't need it but a more complex one does - and this throws the same error as my more complicated one.

If I use the first x.SetOptions() statement I get:
Code:
Copy      Help
Error (RT) in CSTest:  0x80131600,
    (0,0): error CS1703: An assembly with the same identity 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' has already been imported. Try removing one of the duplicate references.    ?
If I use the second x.SetOptions() statement I get:
Code:
Copy      Help
Error (RT) in CSTest:  0x80131600,
    CSTest(29,24): error CS0234: The type or namespace name 'Tasks' does not exist in the namespace 'System.Threading' (are you missing an assembly reference?).    ?

System.Threading is described here http://msdn.microsoft.com/en-us/library/....task.aspx - it uses the mscorlib.dll.

My guess (and it's only a guess) is that System.Threading was introduced in .NET 4.0 and an earlier version of mscorlib.dll is already loaded?

Code:
Copy      Help
Function [b]CSTest[/b] [help1][/help1]
[code]

out

CsScript x
;x.SetOptions("searchDirs=C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\[]references=System.Core.dll;System.Xml.dll;System.ServiceModel.Web.dll;mscorlib.dll")
x.SetOptions("searchDirs=C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\[]references=System.Core.dll;System.Xml.dll;System.ServiceModel.Web.dll")
x.AddCode("")
IDispatch t=x.CreateObject("Test")

;IDispatch k=t.k ;;error
ARRAY(str) b=t.GetListAsArray ;;OK
for(_i 0 b.len) out b[_i]

IDispatch a=t.a ;;OK
out a.Count
out a.Item(0)
a.Item(0)="newstring"
ARRAY(IDispatch) testStrings = t.testStrings
out F"Length of testStrings array {testStrings.len}"
for _i 0 testStrings.len
,out testStrings[_i].aString
,out testStrings[_i].bString
#ret
using System;
using System.Runtime.InteropServices;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;

public class Test2Strings{
,public string aString {get;set;}
,public string bString;
}
public class Test
{
public List<string> k { get; private set;}
public ArrayList a { get; private set;}
public Test2Strings[] testStrings {get; set;}


public Test()
{
k=new List<string>(); k.Add("string in List");
a=new ArrayList(); a.Add("string in ArrayList");
testStrings = new Test2Strings[3];
for (int i=0;i<testStrings.Length; i++){
,testStrings[i] = new Test2Strings();
,testStrings[i].aString = "First String " + i;
,testStrings[i].bString = "Second String " + i;
,}
}

public string[] GetListAsArray() { return k.ToArray(); }
}
[/code]

Thanks!
#2
QM cannot use .NET v4.0 or v4.5 dlls.
QM uses .NET v3.5. Because it is always installed on Windows 7 and can be installed on Windows XP. Possibly in the future will be added option to use v4.5 instead.
#3
Hi -
I just ran into the same issue with another DLL from another vendor. I found an older DLL from the vendor that works fine with .NET 3.5 today but they are adding new features in a month or two that I would like to take advantage of. I can ask them to compile for a 3.5 target (and they might) but it would be great if .NET 4.5 support was added to QM.

Thanks!


Forum Jump:


Users browsing this thread: 1 Guest(s)