Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am making a desktop application using vb.net.

I have 3 forms one base form and two derived forms.

I have used this code:
Public Class frmmain
    Inherits inheritance1.frmbase


Here inheritance is project name and frmmain is derived form and frmbase is base form.

I am getting an error:
Error 1 Base class 'frmbase' specified for class 'frmmain' cannot be different from the base class 'System.Windows.Forms.Form' of one of its other partial types.
Posted
Updated 13-Jun-11 1:03am
v2
Comments
Dalek Dave 13-Jun-11 7:03am    
Edited for Grammar, Spelling and Readability.

Try to this...

First Create Base form and then go to add new item and select Inherited form and then select Base form.
This through you get inherited base form....

also try this link...

http://www.codeproject.com/KB/dotnet/BestFormInheritance.aspx
 
Share this answer
 
v2
Comments
Dalek Dave 13-Jun-11 7:03am    
Good Call.
Ah, this just seems to be a VS bug (or feature ?). You should have a blue squiggly line underneath the inheritance.frmbase line. This should give you the option of changing the declaration to exactly the same thing inheritance.frmbase. Just select that and the error should resolve itself.

Hope this helps
 
Share this answer
 
Comments
shivani 2013 13-Jun-11 7:03am    
thanx
but why i got this error..i mean same thing written but now no error
Wayne Gaylard 13-Jun-11 7:19am    
No idea!
Dalek Dave 13-Jun-11 7:03am    
Sage advice.
shivani 2013 13-Jun-11 7:21am    
ah!then get an idea sir jeee
i mean there will be some logic for this
With VB in WinForms, you actually have two partial classes: one with your code, and one with the automatically generated designer code. When you go to the code of a form, you see where your code is written. From that page, go to the drop-down in the upper right and note the two methods that are grayed out, Dispose(boolean) and InitializeComponent. Select either of those, and you are taken to the other code module, with the code that VS generates automatically to manage the form.

Both of these modules must inherit from the same class. When they do not, the compiler cannot merge the modules into the single form class, and you get your error. So after setting the Inherits in your code module, go to the designer module and change Inherits System.Windows.Forms.Form to Inherits frmmain. Harmony will be restored.
 
Share this answer
 
v2
Comments
sata1m 5-May-15 7:07am    
Worked wonderfully.
Thank you!
Vinicius Viana 5-Jul-19 15:33pm    
Thank you! It worked!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900