rhyous / WPFSharp.Globalizer

Other
26 stars 11 forks source link

Application cannot find static Main Method after installing #13

Closed AndreasReitberger closed 5 years ago

AndreasReitberger commented 5 years ago

Hi, I installed your package via NuGet. Now my application cannot be started any more. That's the issue from VS2017: CS5001 The program has now static method which can be used as entry point (translated from German).

I tried two projects, same problem. I made the adjustments to the app.xml / app.xml.cs file

app.xml.cs

using WPFSharp.Globalizer;

namespace UI
{
    /// <summary>
    /// Interaktionslogik für "App.xaml"
    /// </summary>
    public partial class App : GlobalizedApplication
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            // get the current app style (theme and accent) from the application
            // you can then use the current theme and custom accent instead set a new theme
            Tuple<AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);
            Configuration MyConfiguration = Configuration.Instance;
            Design design = Design.Instance;
            // now set the Green accent and dark theme
            if (design.THEME_NAME != null && design.THEME_APP_STYLE != null)
            {
                var t = design.THEME_NAME;
                var z = design.THEME_APP_STYLE;
                ThemeManager.ChangeAppStyle(Application.Current,
                                            (design.THEME_NAME),
                                            (design.THEME_APP_STYLE)); // or appStyle.Item1
            }
            System.Threading.Thread.CurrentThread.CurrentUICulture = design.GENERAL_LANGUAGE;
            base.OnStartup(e);
        }

        public App()
        {
            //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en"); 
        }
    }
}

app.xml

<globalizer:GlobalizedApplication x:Class="UI.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
             xmlns:globalizer="clr-namespace:WPFSharp.Globalizer;assembly=WPFSharp.Globalizer"
             xmlns:local="clr-namespace:UI"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
                <!-- Accent and AppTheme setting -->
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Steel.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <!-- NEEDED FOR HAMBURGER MENU STYLE -->
            <Style TargetType="{x:Type Controls:WindowButtonCommands}"
                   BasedOn="{StaticResource MahApps.Metro.Styles.WindowButtonCommands.Win10}" />
            <!-- CENTERS ALL MENU ITEM HEADERS -->
            <Style x:Key="{x:Type MenuItem}" TargetType="{x:Type MenuItem}">
                <Setter Property="HeaderTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <ContentPresenter HorizontalAlignment="Left" VerticalAlignment="Center" Content="{Binding}" />
                        </DataTemplate>
                    </Setter.Value>
                </Setter>

            </Style>
        </ResourceDictionary>
    </Application.Resources>
</globalizer:GlobalizedApplication>

Did I miss anything?

Thanks for helping!

AndreasReitberger commented 5 years ago

Fixed it by my own. The "Build type" of the App.xaml file needs to be set to "ApplicationDefinition". Then it works. Sorry for bothering you.