0

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.

1 Answer 1

1

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/

Sign up to request clarification or add additional context in comments.

6 Comments

I've already done it. I've decorated the library by adding the neutralresourceslanguage but it works only if i put as neutral the culture i have in the exception ( in my system is "it-IT" ). If i launch the application in another machine, as i said above, with a different culture, i receive the exception again ( with "en-US" ). I'm quite sure there's something i'm not getting at all. Do i have to build this 3rd party dll for each culture?
Maybe the real question at this point is, how i can disable multiple cultures settings? Is there a way to do that?
Are you sure the decoration is in each consuming assembly? Also, you may need to set the so-called UltimateResourceFallbackLocation. You can also take a look at the <UICulture> element of your .csproj file. I don't know Xceed or what the additional components are, but given what you've written, you may be in for a rebuild.
I changed it on my exe, FSMExtension.dll, a common lib used by both and on exceed.dll. I've rebuilt all of them but nothing is changed. UICulture tag is not present at all in any csproj file. I'm stucked :(. I've made a try by creating a custom dll with a custom user control and import it like i've done for exceed. In this case i've no problem.
Indeed. Your success would be predictable because you have covered all the bases in an isolated case, essentially validating everything on this page. Despite the value of the question/answer here, your next port of call would be the cognizant tool kit developer (singular), if I recall correctly he's in Montreal and questions about the tool kit (versus their commercial product) are not the highest priority. But that's my own experience, yours could be resoundingly different.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.