Public ReadOnly Property cpAssembly() As System.Reflection.Assembly Get Return Me.m_Assembly End Get End Property Sub New() '//获取VB编译器实例 Me.m_Compiler = New VBCodeProvider().CreateCompiler '//初始编译器参数 Me.m_CompilerParameters = New CompilerParameters With Me.m_CompilerParameters .GenerateExecutable = False '//False值指定编译为类集,True编译为可执行程序 .GenerateInMemory = False '//只在内存中生成程序集,不输出到磁盘 '//添加默认的程序集 Me.Add_CompilerParameters() End With End Sub '//添加要引用的程序集 Private Sub Add_CompilerParameters() Me.m_CompilerParameters.ReferencedAssemblies.AddRange(Me.m_RefAssemblies) End Sub '//添加指定的引用程序集 Public Sub Add_CompilerParameters(ByVal RefAssemblies As String()) Me.m_RefAssemblies = RefAssemblies Me.m_CompilerParameters.ReferencedAssemblies.Clear() '//清除原有的程序集,重复引用编译会产生异常 Me.Add_CompilerParameters() End Sub '//生成默认的源代码 '//类名:tmpClass '//函数名:GetExpressionValue ,参数:Expression ,参数类型:字符串 '//主要功能:返回表达式Expression的值 ,返回值类型:Object |