.NET Forum / Windows Forms / Design Time / April 2007
Form Load - Designer Exception
|
|
Thread rating:  |
Giorgio Parmeggiani - 01 Apr 2007 21:53 GMT Hi
I'am developing a Windows Form application (.NET 2.0, VisualStudio 2005 SP1, Infragistics 2006 suite). I open my solution (several project and forms, forms are inherit from base templates) and all works, after i compile my solution, if i try to open any Form the designer give me this exception:
"Impossibile caricare uno o più tipi richiesti. Per ulteriori informazioni, recuperare la proprietà LoaderExceptions (in english: Impossible to load one or more types. For further information, view LoaderExceptions).
in System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark) in System.Reflection.Assembly.GetTypes() in Microsoft.VisualStudio.Shell.Design.AssemblyObsoleteEventArgs..ctor(Assembly assembly) in Microsoft.VisualStudio.Design.VSDynamicTypeService.ReloadAssemblyIfChanged(String codeBase) in Microsoft.VisualStudio.Design.VSDynamicTypeService.CreateDynamicAssembly(String codeBase) in Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_Assembly() in Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, String description) in Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchProjectEntries(AssemblyName assemblyName, String typeName, Boolean ignoreTypeCase, Assembly& assembly) in Microsoft.VisualStudio.Design.VSTypeResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType refType) in Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase) in Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name) in System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.GetType(String typeName) in System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager) in System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager) in Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager) in Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload) "
I close the solution, open VS2005 and all it's ok i can view and modify my form, i compile the solution, try to open a form and...... the same exception!!
I am terribly frustrated, I don't succeed in resolving this problem.
Thank for any suggestion
Giorgio Parmeggian
Linda Liu [MSFT] - 02 Apr 2007 05:09 GMT Hi Giorgio,
Based on my understanding, you have several WinFoms application projects which contain some inherited forms. You could open these projects and all inherited forms without any problem. However, after you compile your solution, and then open any form in the designer, an exception occurs. If I'm off base, please feel free to let me know.
To make things clear, I'd like to ask you several questions:
1. You have mentioned 'Infragistics 2006 suite'. Is it a 3rd party component?
2. > forms are inherit from base templates... What're the 'base templates'? Are they related to the 'Infragistics 2006 suite'?
3. Are all forms that have the problem inherited from base templates?
In fact, if a form is inherited from a base form, when we open it in the designer, an instance of the base form is created first and then the InitializeComponent method of the currently opened form is executed. If we couldn't open this from in the designer, we may narrow down the problem by the following steps:
1. Change the base form of the form to be opened to System.Windows.Forms.Form.
2.Build the project and re-open this form in the designer to see if it could be opened properly. If no, the problem is at least related to the code in the InitializeComponent method of the currently opened form; otherwise, the problem is related to code in the base form.
3. If the problem is at least related to the code in the InitializeComponent method, you may comment out all code in the InitializeComponent method and re-open the form to see if it could be opened correctly. If yes, you may uncomment some of the code in the InitializeComponent method and re-open the form to see if it could be opened. Repeat doing this until the form could not be opened correctly and thus you find the exact code which cause the problem. Correct these code to ensure the form could be opened properly.
4. Restore the form's previous base form.
5. Comment out all the code in both the base form's constructor and Load event handler if any. Build the project and re-open the derived form in the designer to see if it could be opened. If yes, uncomment some of the code in the base form's constructor or Load event handler, and build the project again. Re-open the derived form to see if it could be opened. Repeat this until the derived form couldn't be opened. Then you find the exact code that cause the problem. You may fix the problem by correcting these code.
You may try my suggestion if it's appropriate to your practice and let me know the result.
If you have anything unclear, please feel free to let me know.
Sincerely, Linda Liu Microsoft Online Community Support
================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Giorgio Parmeggiani - 02 Apr 2007 20:32 GMT Hi Linda, thank or your reply
> Based on my understanding, you have several WinFoms application > projects which contain some inherited forms. You could open these > projects and all inherited forms without any problem. However, after > you compile your solution, and then open any form in the designer, an > exception occurs. If I'm off base, please feel free to let me know. Yes it's true
> 1. You have mentioned 'Infragistics 2006 suite'. Is it a 3rd party > component? Yes is a 3rd party component
> 2. > forms are inherit from base templates... > What're the 'base templates'? Are they related to the 'Infragistics > 2006 > suite'? THe 'base templates' contain Infragistiscs Control: i.e. UltraTextBox or UltraLabel
> 3. Are all forms that have the problem inherited from base templates? Yes
I have apply your suggestion and i have discovered that my problem is not related to the base form but is due to the single form.
I have found a simple example that shows my problem: If i simply recompile the solution without any any change is all ok, i can load all forms in the designer But if i change a class (for example the class 'Library') and recompile my solution i can not load any forms in the designer.
In my example the structure of my application is: 'FormA' inherit from 'System.Windows.Forms.Form', 'FormA' contain also a UserControl: 'UC1' (but this behavior happens even if i use a custom control which inherit from 'System.Windows.Forms.Control') which use the class 'Library', if i change and recompile the class 'Library' i can not load FormA in my designer. You have to Notice that 'FormA' and 'UC1' correctly referenced the same 'Library' class. I i delete 'UC1' from FormA, the form is correctly loaded!
If i close the solution e reload it in VS2005 'FormA' is correctly loaded in the designer
Thank in advance
Giorgio Parmeggiani
Giorgio Parmeggiani - 02 Apr 2007 23:09 GMT Perhaps i have found a solution, the 'Library' (and some other classes) class was converted from 1.1 to 2.0, and the Assembly.info have an old format: [assembly: AssemblyVersion("1.0.*")]. I have updated it to the new format (fixed the version number): [assembly: AssemblyVersion("1.0.0.0")]..... and now my problem seems to be resolved!
Giorgi
Giorgio Parmeggiani - 03 Apr 2007 00:09 GMT Hello Giorgio,
> Perhaps i have found a solution, the 'Library' (and some other > classes) class was converted from 1.1 to 2.0, and the Assembly.info [quoted text clipped - 4 lines] > > Giorgio Sigh! Sigh! Sigh!..... my probem is not resolved i have the same exception :
Linda Liu [MSFT] - 03 Apr 2007 09:10 GMT Hi Giorgio,
Thank you for your detailed feedback.
When a form containing a UserControl is opened in the designer, the code in the UserControl's constructor and Load event handler if any, will be executed.
You may have a try commenting out all code in the UserControl's constructor and Load event handler. Build the project and reopen the form to see if the problem still exists.
If you could reopen the form without problem, you may use the method of 'commenting and uncommenting' I suggest in my first reply to fix the problem.
You have mentioned that the class "Library" was converted form .NET 1.1 to 2.0. I think a final try is to create a new class library in .NET 2.0 to see if it helps.
Hope this helps.
Sincerely, Linda Liu Microsoft Online Community Support
Sugandh Jain - 04 Apr 2007 18:45 GMT Is there no better solution to this problem? I think many developers have been suffering from this strange strange problem, Even I did.
Giorgio,
I use almost all the things you use in my windows forms application.. i.e. infragistics, .net 2.0 and visual studio .net 2005.
And I also used to get bugged by the same problem.
commenting and uncommenting the code will be equally frustrating as closing and opening the project/solution again.
The point that Linda mentions in her last post that, Constructor and the Load Method of the control inside your form may be causing the problem is the right thing. So, how do you go about avoiding this problem. Here's is what I suggest...
I suppose you dont write your own code in the control's constructor. If there is some I think it can be removed and put at the place I suggest you next.
In all your controls put the code which actually loads the contents on your control into a method say :-
InitControl() or PopulateControl()
Put the code of constructor and the control1_Load() mehod in this method.
Now, you will need to call this method from the control's parent form explicitly on some event on the form. Infact, Even if you call this method from the Form's Load method, you will get rid of the problem.
Actually, I think you must be making some database calls in load or something else which the environment is not able to get to when it opens the form or control in design time, I think its rightly said by Linda in her first reply that Instance of the Base Form is created, and then the form and then it goes to the contained control's constructors and load methods. Remove code from there and it will help.
Hope this help, please reply to me in case you need more clarification.
Sugandh Jain
> Hi Giorgio, > [quoted text clipped - 24 lines] > Linda Liu > Microsoft Online Community Support Giorgio Parmeggiani - 04 Apr 2007 21:51 GMT Hi Sugandh, Hi Linda The problem finally seems resolved, at least I hope for it :) I think that my problem was due to the Library class (converted from 1.1 to 2.0) i have deleted the Library project and created under VS2005. I have also deleted all "bin" and "object" folders and recompiled my solution. Now seems all ok, i have changed e and recompiled my solution several times and nothing happens. Following the Linda suggestion, i have commented all line in my InitializeComponent() metod (designer class) and the form is correctly loaded, if i add this line of code controlBindingSource.DataSource = _myBusinessClass; the form is not loaded, i think this was very strange and is not due to the initialize or load method of a control
> Here's is what I suggest... > I suppose you dont write your own code in the control's constructor. [quoted text clipped - 14 lines] > from the Form's Load method, you will > get rid of the problem. Thank for your suggestion i will be very useful.
Thank Giorgio
P.S. Excuse me if i have not been clear but I still find it hard to write in English ;)
Linda Liu [MSFT] - 06 Apr 2007 10:29 GMT Hi Giorgio,
Thank you for your detailed feedback.
I'm glad to hear that the problem has been solved.
> if i add this line of code controlBindingSource.DataSource = _myBusinessClass; the form is not loaded, i think this was very strange and is not due to the initialize or load method of a control
I'm not sure but maybe the reason is that it causes other code that breaks the designer to be executed at design time.
If you have any question in the future, please don't hesitate to contact us. It's always our pleasure to be of assistance!
Have a nice weekend!
Cheers,
Linda Liu Microsoft Online Community Support
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|