User Control with presenter problem

Topics: Web Client Software Factory, Project Management Forum, User Forum
Apr 8, 2008 at 10:14 AM
Edited Apr 8, 2008 at 1:36 PM
Hi
I want to create multiple user controls which can access my web service proxies and therefore I thought a User Control with a presenter was the thing.
As default when you "Add a User Control with a presenter" the presenter and controller is placed in the Shell. I will have multiple User Controls and it's not a good idea to have all these user controls access my services via presenter and controller in Shell, is it?

The Shell module is supposed to be as lightweight as possible as I'm been told. What is the best way to create User Controls (or even Server Controls) that must have access to the services available for the Web Client? The controls are general and shall be used over the hole site.



Apr 9, 2008 at 5:21 PM
Hi,
You can add a new Business Modules (i.e. named “UserControls”) and create your user controls in there.
When you use the recipe “Add a User Control with a presenter” the presenter is placed in the module of the folder that you right clicked (the Shell module if you clicked over the root Web site). Also, you can set the module in the recipe under Module Project:.

You can find an example on how to use an User Control in different modules in the E-CommerceCatalog sample application.

Please let me know if this helps.

Jonathan Cisneros
http://staff.southworks.net/blogs/jcisneros/default.aspx
Apr 15, 2008 at 1:33 PM
I did as you said, Jonathan. I added a new Business Module and called it UserControls. When I add a user control with a presenter I get this Receipe Framework Error:

The wizard failed to execute. The error was: Object reference not set to an instance of an object.

Details:

Microsoft.Practices.WizardFramework.WizardExecutionException: The wizard failed to execute. The error was:
Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Practices.WebClientFactory.CustomWizardPages.CreateViewPageBaseModel.FilterProjectsWithVirtualPathNotNullAndContainedInCurrentWebsite(List`1 moduleProjects, DependantModuleInfo[] moduleInfos, IList`1 webFolders)
at Microsoft.Practices.WebClientFactory.CustomWizardPages.CreateViewPageBaseModel.get_ModuleProjects()
at Microsoft.Practices.WebClientFactory.CustomWizardPages.CreateViewPageBasePresenter.OnViewReady()
at Microsoft.Practices.WebClientFactory.CustomWizardPages.CreateViewPageBase.InitializePresenterAndModel()
at Microsoft.Practices.WebClientFactory.CustomWizardPages.CreateViewPageBase.OnLoad(EventArgs e)
at System.Windows.Forms.UserControl.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at Microsoft.WizardFramework.WizardForm.Start(IWin32Window parent)
at Microsoft.Practices.WizardFramework.WizardGatheringService.Microsoft.Practices.Common.Services.IValueGatheringService.Execute(XmlElement data, Boolean allowSuspend)
--- End of inner exception stack trace ---
at Microsoft.Practices.WizardFramework.WizardGatheringService.Microsoft.Practices.Common.Services.IValueGatheringService.Execute(XmlElement data, Boolean allowSuspend)
at Microsoft.Practices.RecipeFramework.Recipe.Execute(Boolean allowSuspend)
at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(String recipe, IAssetReference reference, IDictionary arguments)
at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(IAssetReference reference)
at Microsoft.Practices.RecipeFramework.RecipeReference.OnExecute()
at Microsoft.Practices.RecipeFramework.AssetReference.Execute()
at Microsoft.Practices.RecipeFramework.VisualStudio.RecipeMenuCommand.OnExec()
at Microsoft.Practices.RecipeFramework.VisualStudio.AssetMenuCommand.Invoke()
Apr 15, 2008 at 2:14 PM
Edited Apr 15, 2008 at 2:15 PM
This happens because the web site folder I'm clicking on is not associated with an Business Module though this is the web sitefolder the receipt put the web.config and default.aspx when I created the Business Module.
Its strange. But I guess this can have something to do with that this project is converted from the older version of WCSF. Maybe...? Can the history etc. be removed so I'm able to work without the history haunt me?
Jun 16, 2008 at 10:25 PM

Hey RightCoder;

       I had the exact same error. The project I am working on has the shell project linked in. That project was never upgraded. It had the old CompositWeb, ObjectBuilder... Once I upgraded that project all was good. I spent way too much time searching for how the envdte finds the IsModuleProject, which I think is the source of the error. I never discovered that bit of magic.

Jay