【问题标题】:vb.net Replace existing class with CodeDoms generated classvb.net 用 CodeDoms 生成的类替换现有类
【发布时间】:2016-11-21 05:12:30
【问题描述】:

我有这样的课(这只是例子)

class child
   inherits parent1
end class

然后在运行时我希望改变变成这样

class child
   inherits grandfatherclass
end class

我一直在尝试使用这样的代码,遗憾的是它仍然继承自 parent1

Dim onewclass As CodeDomProvider = CodeDomProvider.CreateProvider("VB")
Dim objCompilerParameters As New CodeDom.Compiler.CompilerParameters
Dim classString as string = "class child" & vbnewline & _
                            "     inherits grandfatherclass" & vbnewline & _
                            "end class"
onewclass.CompileAssemblyFromSource(objCompilerParameters, classString)

是否可以用 CodeDom 生成的类替换现有的类...?

【问题讨论】:

    标签: vb.net codedom


    【解决方案1】:

    您不能用 CodeDom 替换现有的类。相反,您可以根据需要创建一个新的派生类。您可以进一步继承它以满足您的需要。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-25
      • 2011-11-19
      • 2019-01-17
      • 1970-01-01
      • 1970-01-01
      • 2019-10-10
      • 1970-01-01
      相关资源
      最近更新 更多