Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Form Inheritance and Inheritance Picker problem
 

Form Inheritance and Inheritance Picker problem

Hi everyone:

I have some base forms and usercontrols in a project named "UILibrary". And I create derived forms and derived usercontrols in other several projects. Everything goes very well. After a period of time, the solution grows and I modified classes in "UILibrary" and built it several times.
The problem is coming. When I wnat to add a new item, also select Inherited Form or Inherited Usercontrol template, an "Assembly Load Error" message box shows. The message is "Unable to load assembly 'D:\Ap\UILibrary\obj\Debug\UILibrary.dll'. Ensure that the file is a valid .Net Framework assembly." 
Then the Inheritance Picker shows you a message too: "Warning: No built assemblies contain components to inherit from. Build the current application, or click Browse and select a previously built assembly from another application." 
I try to click Browse button and select UILibrary.dll manually but get an "Assembly Load Error" again.

So, what is going wrong? Any idea about this problem?
thanks in advance

Hubble T  Monday, September 04, 2006 8:27 AM
I encountered the same error message today trying to build a new form. I had just finished creating a new form and rebuilt the solution. I tested out the new form and it worked. So I tried to create another form. I clicked on the "inherited form" and then the "ADD" button. That is when the "Assembly Load Error" was displayed. I, too, would appreciate any suggestions on how to correct this problem. Thank you.
NETBowler  Wednesday, September 06, 2006 10:57 PM

Hello NETBowler:

What Ican do is"try and error". Stupid but sometimes works.In my experience, what i try to do are :

1.close visual studio,(even reboot PC!),reopen visual studio and solution

then

2.remove references in projects and add them back, clean solution, rebuild solution

more

3.do some changesto the project (UIlibrary in my case) such as remove cs files and add them back, clean solution, rebuild solution

However, no idea about the really reason result in the problem do bother me. IfI need to add inherited form or usercontrol evermore, I am most likely to encounter the problem again and again. And it would wastetime a little.

Hubble T  Tuesday, September 12, 2006 3:14 AM
I had some old compiled code in the repository sinceI had includedmy obj and bin folders into the repository, Ialso have the .suo files included in the repository. None of those directories or files should be included in the repository as they are artifacts created during each compile run (or the .suo file is a user specific file and should also not be in the repository. I checked my TortoiseSVN setting (from Windows Explorer File->TortoiseSVN->Settings and ensurethat myGlobal ignore patter contains at least the following:
thumbs.db *.exe *.dll *.obj *.ncb *.lib *.idb *.pdb *.ilk *.msi *.res *.pch *.suo *.aps *.*~ *.~* ~*.* cvs release debug bin obj *.user *-results.xml bin\*.xml bin\debug\*.xml bin\release\*.xml *.vspscc *.scc *.vssscc *.bak */bin */obj */temp
Once that done, I removed the artifact directories from the repository. Then I checked out a new working copy in a clean directory.After rebuilding the solution, I still got the load assembly error.
So, I tried another thing. I deleted both the bin and obj folders from the PIM.Business and PIM.Win. I rebuilt the solution, but again, same error. Still looking... Thanks for the suggestions...
NETBowler  Tuesday, September 12, 2006 6:56 PM

I am experiencing the same error.

I am trying to add a new inherited form to the same project that contains the formit is toinherit from.

Any ideas yet?

wsaunders  Wednesday, September 13, 2006 4:57 PM

I did some serious searching on our Load assembly error and located the following solution.

I have a workaround to this.

This error usually occurs to me when the form designer try to load an object that doesnt exists on form. From what I saw, it can happen in some situations, specially if youuse inherited forms. The form designer in some cases don't remove the generated code for removed components, when you try to open the form again it will try to access the component but it willnot exist on your form.

To fix this you should edit your form andyour designer code, and look for declared objects that doesnt exists on your form or your base form. Remove any unused declarations, clean the solution and close the visual studio.

Each form is consisted of 3 files form.vb, form.resx and form.designer.vb (or .cs if you use C#). To edit the last 2 files you need to choose the show all files option on Solution Explorer Window.

Open it again, rebuild your solution and it will work.

I opened up my Visual Studio solution and discovered on of my test forms was missing the form.resx. I deleted the bad form, rebuilt the solution, tried to add another inherited form, and it worked!

I hope this helps.

NETBowler  Wednesday, September 20, 2006 6:56 PM

You can use google to search for other answers

Custom Search

More Threads

• Custom Control
• how to keep ours form on top (in front) by using VB
• Newbie Question
• Appbars
• Form Designer at runtime
• RootComponentDesigner Add component
• Rectangle on Middle Task bar not indenting when highlighted
• How to highlight a row on selecting a row on tablelayoutpanel
• Mask validation on Windows form text boxes
• Saving/Retrieving changes made in the propertygrid control.