vb.net Replace existing class with CodeDoms generated class

限于喜欢 提交于 2019-12-25 17:55:33

问题


I've class like this (it's just example)

class child
   inherits parent1
end class

and then at runtime i want change become like this

class child
   inherits grandfatherclass
end class

I've been trying with code like this, sadly it's still inherits from 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)

Is it possible to replace existing class with CodeDom generated class...?


回答1:


You cannot replace existing class with CodeDom. Instead you can create a new derived class and if you want. You can further inherit it again to suit your need.



来源:https://stackoverflow.com/questions/40713182/vb-net-replace-existing-class-with-codedoms-generated-class

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!