-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
Area-InteractiveConcept-APIThis issue involves adding, removing, clarification, or modification of an API.This issue involves adding, removing, clarification, or modification of an API.
Milestone
Description
Version1.3.2:
Code:
var references = new List<Assembly>();
var imports = new List<string>();
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
if (assembly.FullName.Contains("mscorlib"))
{
continue;
}
if (assembly.IsDynamic)
{
continue;
}
if (string.IsNullOrEmpty(assembly.Location))
{
continue;
}
references.Add(assembly);
try
{
var namepsaces = assembly.GetTypes()
.Where(t => string.IsNullOrWhiteSpace(t.Namespace) == false)
.Select(t => t.Namespace);
foreach (string item in namepsaces.Distinct())
{
imports.Add(item);
}
}
catch (System.Reflection.ReflectionTypeLoadException reflx)
{
Console.WriteLine($"Skipping assembly {assembly.FullName}. Err: {reflx}");
}
}
references = references.Distinct().ToList();
imports = imports.Distinct().ToList();
#endregion
var options =
ScriptOptions.Default.AddImports(imports)
.AddReferences(references);
//var path = System.Reflection.Assembly.GetAssembly(typeof(System.Data.DataTableExtensions)).Location;
//var asm = Microsoft.CodeAnalysis.AssemblyMetadata.CreateFromFile(path).GetReference();
//var options =
// ScriptOptions.Default.WithImports("System", "System.Data", "System.Linq")
// .AddReferences(asm)
// .AddReferences(references)
// .AddReferences((typeof(System.Linq.Enumerable).Assembly))
// .AddReferences((typeof(System.Data.DataSet).Assembly)).AddReferences((typeof(System.Data.DataTable).Assembly));
var globals = new Globals() { };
try
{
scriptState = scriptState == null ? CSharpScript.RunAsync(code, options: options, globals: globals).Result : scriptState.ContinueWithAsync(code, options: options).Result;
if (scriptState.ReturnValue != null)
return scriptState.ReturnValue;
return null;
}
catch (CompilationErrorException error)
{
Console.WriteLine(error.ToString());
; return null;
}
- code segment ,when i run it , caused a CompilationErrorException error
error CS0234: The type or namespace name 'Thunk' does not exist in the namespace 'System.EnterpriseServices' (are you missing an assembly reference?) - i add reference

it doesn't work
3.i usereferences.Add(Assembly.Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"));it doesn't work .
question:
Can anyone help me with this problem?
Expected Behavior:
Actual Behavior:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-InteractiveConcept-APIThis issue involves adding, removing, clarification, or modification of an API.This issue involves adding, removing, clarification, or modification of an API.