Inheritance

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a solution with 3 projects - 1 exe and two dll's

In the exe I usually inherits forms from one of the dll's (main-classes etc). Now I want to add an inherited form from within the exe. But when I try I get the error "Ensure that the file is a valid .Net Framework Assembly" - and I cannot select a parent form from the forms in my exe

And I am quite sure that the exe is a "valid .Net Framework Assembly" - I really can't see what else it could be....and for that reason, how to "make sure"...

Regards benny
 
Ok dont kill me if I am wrong, but this is what I think.
Every form itself inherits from System.Windows.Forms.Form

Now if you want to create a form that inherits from another form in the same
assembly, fundamentally you wont be able to do it because the moment you add
a form to your Project that form is going to inherit from
System.Windows.Forms.Form (By default)

So the only way you can add inheritance to a form is via referencing to
external assembly
for e.g.

Public Class frmNewForm
Inherits MyformAssembly

Where MyFormAssembly is a form which is basically inherting from
System.Windows.Forms.Form

Abhi


Benny said:
I have a solution with 3 projects - 1 exe and two dll's.

In the exe I usually inherits forms from one of the dll's (main-classes
etc). Now I want to add an inherited form from within the exe. But when I
try I get the error "Ensure that the file is a valid .Net Framework
Assembly" - and I cannot select a parent form from the forms in my exe.
And I am quite sure that the exe is a "valid .Net Framework Assembly" - I
really can't see what else it could be....and for that reason, how to "make
sure"....
 
No - that is not the problem. If you were right inheritance would be disabled in one-project solution...and besides I have successfully inherited from within the same project previously

This problem was solved by removing the reference "WMPLib" in the project (some Window Media Player stuff...). So it seems that using Windows Media Player in a project invalidates inheritance in some way.

"Solved" this I managed to inherited a form from my within my exe. Next problem is that it the windows forms designer returns the error "The service System.Windows.Forms.Design.IEventHandlerService already exists in the service container. Parameter name: serviceType"....How to solve that???

Regards
benn
 
Yep my bad, you can actually inherit from a form within the same assembly. I
tried it today and it worked perfect for me.




Benny said:
No - that is not the problem. If you were right inheritance would be
disabled in one-project solution...and besides I have successfully inherited
from within the same project previously.
This problem was solved by removing the reference "WMPLib" in the project
(some Window Media Player stuff...). So it seems that using Windows Media
Player in a project invalidates inheritance in some way.
"Solved" this I managed to inherited a form from my within my exe. Next
problem is that it the windows forms designer returns the error "The service
System.Windows.Forms.Design.IEventHandlerService already exists in the
service container. Parameter name: serviceType"....How to solve that????
 
Back
Top