PrismV2 Drop 3 - Only one InitializationMode (WhenAvailable) works

Oct 17, 2008 at 11:33 PM

Are you aware of that when using InitializationMode anything else than "WhenAvailable" the module is not getting loaded?

I was getting this error on my prototype exercise code while trying to use WithApp or OnDemand.  It seems like bug as I can reproduce this error on RemoteModuleLoading sample provided on the drop 3 when changing the InitializationMode to either WithApp or OnDemand.

Regards,
Alexander

Nov 14, 2008 at 5:31 PM
Edited Nov 14, 2008 at 5:48 PM
Hi Alexander,

The WithApp initialization mode will cause an exception if used on remote groups, because this mode does not call a module retriever to retrieve the group, instead it tries to obtain the group and its modules from the local context.
Let's analize the Run method of the ModuleManager class:

public void Run()
{
    foreach (ModuleInfoGroup coreGroup in this.moduleCatalog.GetCoreGroups())
    {
        //If the group is set as core it will not retrieve the group, it assumes it is already available and will try to initialize its modules generating an exception
         this.InitializeModules(coreGroup.Modules);
    }

    foreach (ModuleInfoGroup backgroundGroup in this.moduleCatalog.GetBackgroundGroups())
   {
        //On the other hand background groups are not only initialized but also retrieved
        this.RetrieveGroupAndInitialize(backgroundGroup);
   }
}


However, using OnDemand initialization mode for a group should work, since they work similar to background groups.
This issue is now mentioned in the Composite Application Guidance documentation that will be available on the next drop.
Thanks a lot for your feedback.

Diego Poza
http://blogs.southworks.net/dpoza
Nov 14, 2008 at 5:46 PM
Thanks for the info. I think i tried to use WithApp and OnDemand on code drop 4 sample and both cases I got same execption. But I will revalidate this  based on code drop 5 and see if this happend again.

Regards,
Alexander
Nov 14, 2008 at 6:16 PM

Diego,

I revalidate this with code drop 5, and I am still get an exception if I want to load module only explicitly when requested.

 

I was able to re-procedure this by using the RemoteLoadingSample, this case I changed the all modules InitializationMode="OnDemand" and exception occurred.

 

According to current help available on code drop 5 in quick starts:  
·  " On Demand groups: Groups that are marked as OnDemand on the InitializationMode property. These groups will only be downloaded when explicitly requested."

Am I erroneous assuming here the module loading facility or should below change on InitializationMode work on RemoteLoadingSample?

<

 

Modularity:ModuleInfoGroup Ref="ModuleX.Silverlight.xap" InitializationMode="OnDemand">
<Modularity:ModuleInfo ModuleName="ModuleX" ModuleType="ModuleX.ModuleX, ModuleX.Silverlight, Version=1.0.0.0" />
</Modularity:ModuleInfoGroup>
<Modularity:ModuleInfoGroup Ref="ModulesWY.Silverlight.xap" InitializationMode="OnDemand">
<Modularity:ModuleInfo ModuleName="ModuleY" ModuleType="ModuleY.ModuleY, ModulesWY.Silverlight, Version=1.0.0.0" />
<Modularity:ModuleInfo ModuleName="ModuleW" ModuleType="ModuleW.ModuleW, ModulesWY.Silverlight, Version=1.0.0.0" />
</Modularity:ModuleInfoGroup>
<Modularity:ModuleInfoGroup Ref="ModuleZ.Silverlight.xap" InitializationMode="OnDemand">
<Modularity:ModuleInfo ModuleName="ModuleZ" ModuleType="ModuleZ.ModuleZ, ModuleZ.Silverlight, Version=1.0.0.0" />
</Modularity:ModuleInfoGroup>

 

Nov 19, 2008 at 5:36 PM
Edited Nov 19, 2008 at 5:45 PM
Alexander,
The Remote Modularity QuickStart in the 5th drop includes an example of OnDemand Loading. If you look at the module catalog (ModulesCatalog.xaml) you will see that the group that contains Module X will be initializated on demand.

<Modularity:ModuleInfoGroup Ref="ModuleX.Silverlight.xap" InitializationMode="OnDemand">
<Modularity:ModuleInfo ModuleName="ModuleX" ModuleType="ModuleX.ModuleX, ModuleX.Silverlight, Version=1.0.0.0" />
</Modularity:ModuleInfoGroup>

 

 

The ModuleX module will be initializated when the button in the ModuleY view is pressed. The code that will explicitly request ModuleX initialization is the following (located in DefaultViewY.xaml.cs):

private void LoadModule_ButtonClick(object sender, RoutedEventArgs e)
{
 // This logic is placed in code-behind instead of a presenter 
 // for the ease of demonstrating module loading. 
this.moduleManager.LoadModule("ModuleX");
}

 

 

I tried changing the catalog to set all module groups initialization modes to OnDemand, as your sample, and I do not get an exception, just an empty shell window, which will be the expected behavior (cause no module is loaded).
For more information see the RemoteModularity QuickStart topic in the CHM included in the drop.

I hope this helps you. If not please provide more information about the exception you are getting.

Diego Poza
http://blogs.southworks.net/dpoza

Nov 19, 2008 at 5:44 PM

Yes my mistake as I got this exception in code drop 3 and I assumed that I got the same exception in codedrop 5 re-validation when the screen wasn’t populated.
I am sorry for this confusion and will be more careful in future….

Regards,
Alexander