Reputation: 66
Launching my wpf application and trying to show a particular control i receive this exception:
"FileNotFoundException - Cannot load file or assembly "Xceed.WPF.Toolkit.resources, version=2.0.0.0, Culture=it-IT...."
I know it seems a problem already discussed but my problem is a little bit more specific.
I have my application ( Wolf.exe ) that works with a plugin system. The plugin system load plugin classes from external dll located inside the Extension application folder ( this folder is located at the same level of the .exe ). Plugins are able to load extra resources, like xaml dictionary, and specify custom Styles to extend base components.
One of this plugin/assembly ( FSMExtension.dll ) load extra xaml resources in this way:
FileStream oFileStream = new FileStream(filename, FileMode.Open);
if (oFileStream != null)
{
ResourceDictionary oResourceDictionary = (ResourceDictionary)XamlReader.Load(oFileStream);
if (oResourceDictionary != null)
{
Application.Current.Resources.MergedDictionaries.Add(oResourceDictionary);
}
}
oFileStream.Close();
FSMExtension.dll has a dependency on the "Extended WPF Toolkit™ Community Edition" ( http://wpftoolkit.codeplex.com/documentation ) cause it needs a PropertyGrid component. The resulted xaml has a similar aspect:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:WolfLib.UI.Converters;assembly=WolfLib"
xmlns:xctk="clr-namespace:Xceed.Wpf.Toolkit.PropertyGrid;assembly=Xceed.Wpf.Toolkit">
<converters:BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" IsHidden="false" TriggerValue="false"></converters:BooleanToVisibilityConverter>
<Style x:Key="FSMBlockStyle" TargetType="ContentControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<xctk:PropertyGrid Grid.Row="5" Grid.ColumnSpan="2" Margin="5 0 5 5" Visibility="{Binding ElementName=PropertyToggleButton, Path=IsChecked, Converter={StaticResource BoolToVisibilityConverter}}"
ShowSummary="false"
IsCategorized="true"
ShowAdvancedOptions="false"
IsReadOnly="false"
ShowSortOptions="false"
ShowSearchBox="false"
ShowTitle="false"
AutoGenerateProperties="false"
MaxWidth="300">
<xctk:PropertyGrid.PropertyDefinitions>
<xctk:PropertyDefinition TargetProperties="Name,Type,MainController,Views,ControllerBehaviours,ControllerParams"/>
</xctk:PropertyGrid.PropertyDefinitions>
</xctk:PropertyGrid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
When I apply the specific style to my control I receive the exception above. This exception doesn't occur if i try to use directly the PropertyGrid control inside my Application ( on MainWindow.xaml ). This problem is strange also because i don't have any kind of .resources.dll file for this assembly.
The only way I've found to fix the problem is to specify the default culture assembly for "Extended WPF Toolkit™ Community Edition" and rebuild it.
This fix will work for my machine configuration with a "it-IT" language/culture. If I launch my application in a different machine with e different culture ( i.e en-US ) the exception will be thrown again.
Is there a specific way to deal with this kind of problem ? Let me know if you need more information.
Upvotes: 0
Views: 1929
Reputation: 8792
I don't know specifically how Xceed works, but when using multiple cultures, the assembly must be decorated to indicate the default culture. Otherwise the .NET run-time will complain about not being able to find the resource file. It goes in AssembyInfo.cs
for each consuming assembly:
In desktop apps, the NeutralResourcesLanguageAttribute attribute informs the resource manager of an app's default culture and the location of its resources. By default, resources are embedded in the main app assembly, and you can use the attribute as follows.
The declaration looks like this...
[assembly: NeutralResourcesLanguage("en-GB")]
where "en-GB" specifies the default. If you have trouble finding it, the decorations for an assembly look like this...
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MultiLanguage")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MultiLanguage")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en-GB")]
The documentation is here http://msdn.microsoft.com/en-us/library/system.resources.neutralresourceslanguageattribute.aspx
And there is a WPF reference application with source here https://tcimultilanguage.codeplex.com/
Upvotes: 1