C#窗体和用户控件从VB窗体和用户控件继承。 [英] C# windows forms and user controls inheritance from VB forms and user controls.
问题描述
我有一些VB窗体和用户控件,它们从BaseUserControl和BaseForm等基类继承,我希望它们具有的每个行为我只是将它添加到Base类中,这是一个问题,我的解决方案中的一个项目是用C#编写的,这个项目的表单和用户控件也是从这些VB Base类继承的,但是我添加的功能基类不会被添加到C#类中,
这是我的BaseUserControl,
公共 类 BaseUserControl
继承 System.Windows.Forms.UserControl
受保护的 覆盖 Sub InitLayout()
MyBase .InitLayout()
如果(不 handlerAdded)那么 tryaddinghandler()
TakeMenuEntranceDate()
结束 Sub
< span class =code-keyword>结束 类
这是我的一个用户控件,
公共 类 AveHesab1
继承 Acc.WinUI.Common.BaseUserControl
' ...
结束 类
到目前为止一切顺利,没有问题。
以下是问题,
public class frmMoshakhasatPersonel:Acc.WinUI.Common.BaseUserControl
// ...
结束类
我添加到BaseUserControl中的功能被添加到所有VB用户控件中继承它,但没有C#用户控件获取插入BaseUserControl的行为。
欢迎任何帮助和想法解决它,
谢谢,
我的尝试:
我'我仍在努力,但尚未找到解决方案。
他们确实得到了继承,但你必须首先重建VB项目,或者C#代码无法看到更改。
C#依赖项是它引用的DLL文件,而不是创建DLL的项目的源代码 - 这样你就可以继续工作了该项目,而其他人参考您的发布版本没有任何问题。
只需构建VB项目,然后检查C# - 除非您正在构建调试版本并且C#代码引用了版本DLL,否则它将在此之后看到它。
Hi,
I have some VB windows forms and user controls which they inherit from some base classes like BaseUserControl and BaseForm, every behavior that I want them to have I'll just add it into the Base classes, Here is a problem, one project inside my solution is written in C# and the forms and user controls of this project they also inherit from those VB Base classes, but the functionalities that I add to the base classes will not be added to the C# classes,
It's my BaseUserControl,
Public Class BaseUserControl
Inherits System.Windows.Forms.UserControl
Protected Overrides Sub InitLayout()
MyBase.InitLayout()
If (Not handlerAdded) Then tryaddinghandler()
TakeMenuEntranceDate()
End Sub
End Class
It's one of my user controls,
Public Class AveHesab1
Inherits Acc.WinUI.Common.BaseUserControl
'...
End Class
So far everything goes well and there is no problem.
Here is the problem,
public class frmMoshakhasatPersonel : Acc.WinUI.Common.BaseUserControl
//...
End Class
The functionalities that I add into the BaseUserControl are added into the all VB user controls that inherit from it, but none of the C# user controls Get the behavior inserted into BaseUserControl.
Any help and idea to solve it is welcome,
Thanks,
What I have tried:
I'm still working on it but yet haven't found a solution.
They do get the inheritance, but you have to rebuild the VB project first, or the C# code can't "see" the changes.
The C# dependency is on the DLL file it references, not on the source code for the project that creates the DLL - so that you can continue to work on the project while others reference your release version without any problems.
Just build the VB project, then check the C# - unless you are building the debug version and the C# code is referencing the release DLL, it will see it after that.
这篇关于C#窗体和用户控件从VB窗体和用户控件继承。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!