Strong Naming Assembly causes this exception

Topics: Prism v4 - Silverlight 4
Aug 5, 2011 at 6:46 AM
Edited Aug 5, 2011 at 8:06 AM



After having all my client and Server projects strong named with a keypair, I get this exception when starting the application:


Microsoft JScript runtime error: Unhandled Error in Silverlight Application Unable to retrieve the module type SalesContactManagement.Modules.ContactModule.ContactModule, SalesContactManagement.Modules.ContactModule, Version=, Culture=neutral, PublicToken=null from the loaded assemblies.  You may need to specify a more fully-qualified type name.   at Microsoft.Practices.Prism.Modularity.ModuleInitializer.HandleModuleInitializationError(ModuleInfo moduleInfo, String assemblyName, Exception exception)   at Microsoft.Practices.Prism.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo)   at Microsoft.Practices.Prism.Modularity.ModuleManager.LoadModulesThatAreReadyForLoad()   at Microsoft.Practices.Prism.Modularity.ModuleManager.IModuleTypeLoader_LoadModuleCompleted(Object sender, LoadModuleCompletedEventArgs e)   at Microsoft.Practices.Prism.Modularity.XapModuleTypeLoader.RaiseLoadModuleCompleted(LoadModuleCompletedEventArgs e)   at Microsoft.Practices.Prism.Modularity.XapModuleTypeLoader.HandleModuleDownloaded(DownloadCompletedEventArgs e)   at Microsoft.Practices.Prism.Modularity.XapModuleTypeLoader.IFileDownloader_DownloadCompleted(Object sender, DownloadCompletedEventArgs e)   at Microsoft.Practices.Prism.Modularity.FileDownloader.WebClient_OpenReadCompleted(Object sender, OpenReadCompletedEventArgs e)   at System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs e)   at System.Net.WebClient.OpenReadOperationCompleted(Object arg)


I wonder if somebody could help me how to fix this? Do I have to change the namespace to something else?


This is my config:


    xmlns:x="" xmlns:sys="clr-namespace:System;assembly=mscorlib">
    <Modularity:ModuleInfoGroup InitializationMode="WhenAvailable">
        <Modularity:ModuleInfo Ref="SalesContactManagement.Modules.ContactModule.xap" ModuleName="ContactModule" ModuleType="SalesContactManagement.Modules.ContactModule.ContactModule, SalesContactManagement.Modules.ContactModule, Version=, Culture=neutral, PublicToken=xxx"/>
        <Modularity:ModuleInfo Ref="SalesContactManagement.Modules.NavigationModule.xap" ModuleName="NavigationModule" ModuleType="SalesContactManagement.Modules.NavigationModule.NavigationModule, SalesContactManagement.Modules.NavigationModule, Version=, Culture=neutral, PublicToken=xxx">


PublicToken=xxx  is my public GUID that I got by doing sn.exe -T Contact.Module.dll
I hope this is what was required.




Aug 5, 2011 at 5:07 PM

Hi Houman,

Based on our understanding of your situation, there doesn't seem to be any problems with what you're showing here. In my opinion, you shouldn't need to change the namespace.

Additionally, the exception is saying that the PublicToken is null; is that exception shown when using the module catalog you're describing here?


Guido Leandro Maliandi

Aug 5, 2011 at 5:50 PM

Hi Guido,


Thanks for the response.  Good catch, the initial exception was from last night when I had forgotten putting the public key in there as described above. Hence the null value you have spotted.

But this morning I had a vision and realized it, i have retrieved the GUID as above and ran it again. It made no difference unfortunately. But I forgot to update the initial exception error in this message.

So when you say there is nothing wrong, that's a bad news for me. I am quite stuck on this. :(


Aug 6, 2011 at 11:45 AM

Hi Guido,


I have made some great progress in this case and have almost the solution. I wonder if you could give me an advice this regarding please.

I have deactivated the ModulesCatalog.xaml and am trying to do the same thing in code instead. The first attempt was replicating it exactly and it still failed with the same error message:

protected override IModuleCatalog CreateModuleCatalog()
            //return Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml(new Uri("/SalesContactManagement.Shell;component/ModulesCatalog.xaml", UriKind.Relative));

            ModuleCatalog moduleCatalog = new ModuleCatalog();

            moduleCatalog.AddGroup(InitializationMode.WhenAvailable, "SalesContactManagement.Modules.ContactModule.xap",
                                   new ModuleInfo()
                                           ModuleName = "ContactModule",
                                           ModuleType =
                                               "SalesContactManagement.Modules.ContactModule.ContactModule, SalesContactManagement.Modules.ContactModule, Version=, Culture=neutral, PublicToken=xxx",
                                           Ref = "SalesContactManagement.Modules.ContactModule.xap"
                                   new ModuleInfo()
                                           ModuleName = "NavigationModule",
                                           ModuleType =
                                               "SalesContactManagement.Modules.NavigationModule.NavigationModule, SalesContactManagement.Modules.NavigationModule, Version=, Culture=neutral, PublicToken=xxx",
                                           Ref = "SalesContactManagement.Modules.NavigationModule.xap",
                                           DependsOn = new Collection<string> { "ContactModule" }
             return moduleCatalog;

Then I tried to add them directly by referencing the modules to the Shell:

protected override IModuleCatalog CreateModuleCatalog()

            Type contactModuleType = typeof(ContactModule);
            Type navigationModuleType = typeof(NavigationModule);

            ModuleCatalog moduleCatalog = new ModuleCatalog().AddModule(contactModuleType).AddModule(navigationModuleType, new string[] {"ContactModule"});
            return moduleCatalog;


Surprisingly, this one works. No exception anymore. However it only shows my NavigationModule on the display.  The ContactModule is never showing up. Have I set the dependency correctly?
I even tried without setting the dependency and it didn't affect anything.

Many Thanks,


Aug 8, 2011 at 9:13 AM


Since I could find a solution for Unity, I ended up to convert my project to use MEF.

It was a huge pain. MEF is indeed a very difficult technology to begin with. I found Unity much easier.  But at the end it was worth the effort and now I am understanding MEF also much better.

The result was that I can now strong name my assemblies thanks to MEF and run the app without any problem.    Whatever it was, Unity didn't work very well after all in my scenario.