Error adding MergedDictionary to Application.Resources WPF

I use MVVM light to create a “fast” WPF application to test some web services. I have the whole application, but I need to add the ResourceDictionary resource to the application resources. When I add the following to App.xaml:

<ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Resources/ResourceDictionary.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> 

I get an error message:

Error 4 Program '' does not contain a static “Basic” method suitable for entry point

All the help I can find in this error is related to the fact that the Build action is set to ApplicationDefinition, and this is not a problem.

Any help or guidance is appreciated.

TIA!

+4
source share
2 answers

I had the same error when adding anything to resources in App.xaml while learning MVVM Light Toolkit. The problem is caused by incorrect dictionary declaration in <Application.Resources> and is not related to MVVM Light Toolkit.

The application resource dictionary should look like:

 <Application ...> <Application.Resources> <ResourceDictionary> <!-- Global ViewModelLocator --> <vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" /> <ResourceDictionary.MergedDictionaries> <!-- Global style --> <ResourceDictionary Source="Skin1.xaml" /> <ResourceDictionary Source="Skin2.xaml" /> <ResourceDictionary Source="Templates1.xaml" /> <ResourceDictionary Source="Templates2.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application> 

Thus, you get a working global resource dictionary with the old Locator key in the same place and new keys from the dictionaries declared in the listed files.

The downloaded files are as follows:

 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style TargetType="{x:Type Button}"> <Setter Property="Height" Value="28" /> <Setter Property="Padding" Value="12,3" /> </Style> ... </ResourceDictionary> 
+10
source

Hmm, what error: does your program compile and run before you add the merge word section in App.xaml?

It may be worth checking the properties of your project - it looks like it can be installed in a console application, which by default has a static main method, which is the beginning of the application.

If it is not installed in the Console application - it is still worth checking for the "Launch Object" parameter - this can be set for a specific class, which can again be checked for the static main method as an entry point.

The entry point basically means the first that runs as part of the application.

NTN, Scott

+1
source

Source: https://habr.com/ru/post/1347768/


All Articles