Short: Which assemblies (Framework DLLs) are included by default in .NET CodeDom Compilers (CSharpCodeProvider
or VBCodeProvider
) without explicitely adding the reference to CompilerParameters?
I am using the CodeDom
tools, namely CSharpCodeProvider
and VBCodeProvider
, to compile assemblies at runtime. I noticed, that some but not all .NET reference assemblies are included by default.
I can use everything in System.dll
without adding the reference in the CompilerParameters
but nothing from System.Numerics.dll
for example. For the latter I need to add params.ReferencedAssemblies.Add("System.Numerics.dll")
to my code.
Hence my question: How do I know, which assemblies are referenced by default, and which are not?
Relevant code:
This code can be compiled without added references:
Imports System
Public Class Foo
Public Sub TestClass
Dim t = Tuple.Create(23,241)
End Sub
End Class
This code can not:
Imports System
Imports System.Numerics
Public Class Foo
Public Sub TestClass
Dim t = Tuple.Create(23,241)
Dim n As New Complex(32,112)
End Sub
End Class
The code I use to compile (abbreviated):
Dim params As New CompilerParameters()
'The path of the assembly to create
params.OutputAssembly = active.OutputName
'Compile as dll
params.GenerateExecutable = False
Dim vb As New VBCodeProvider
Dim res = vb.CompileAssemblyFromSource(params, active.Code)