10-05-2013, 04:38 AM
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
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:
If I use the second x.SetOptions() statement I get:
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]
Thanks!
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
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:
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. ?
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?
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(); }
}
Thanks!