1

Closed

Bug in LoadModuleType() of MefFileModuleTypeLoader.Desktop.cs

description

Prism cannot load modules from XAML when using MEF because the first char of the file name will be truncated and a file not found exception is raised.
 
The line in LoadModuleType() in MefFileModuleTypeLoader.Desktop.cs:
 
string path = moduleInfo.Ref.Substring(RefFilePrefix.Length + 1);
 
should be:
 
string path = moduleInfo.Ref.Substring(RefFilePrefix.Length);
 
I.e. Ref = "file://TestModule.dll"
 
After URI parsing:
 
RefFilePrefix = "file://" (Length = 7)
 
In the current release the path ends up with:
 
Ref.Substring(8) =>
 
path = "estModule.dll"
 
Workaround: Write Ref="file://_TestModule.dll" (with an extra character at the beginning) in XAML module catalog.
Closed Dec 2, 2011 at 5:38 PM by aadami
Hi,I'm closing this work item, as the issues reported here are already described in the following work items:http://compositewpf.codeplex.com/workitem/7215http://compositewpf.codeplex.com/workitem/8029Thanks,Agustin Adamihttp://blogs.southworks.net/aadami

comments

GuidoMaliandi wrote Dec 10, 2010 at 6:51 PM

Hi,

You can check a similar issue here: http://compositewpf.codeplex.com/workitem/7215

As mentioned in the issue I've linked to, the product team is aware of this and might tackle the issue in future releases.

Thank you for your feedback.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

bladerunner500 wrote Feb 14, 2011 at 7:36 PM

The code does not handle files with #. Paths with # get escaped, with the result it now contains %23. Why not use string path = uri.LocalPath()? This will also convert / characters from file:// format to correct windows format.