问题
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