合并到main.exe之后的问题 [英] Problems after merging Fluent into main.exe

查看:170
本文介绍了合并到main.exe之后的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是关于 Fluent ,我与我的 program.exe合并在一个merged.exe中使用以下代码:

My Question is about a Fluent, which i merged with my program.exe in one merged.exe with this code:

    public class Program
    {
        [STAThreadAttribute]
        public static void Main()
        {
            AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
            App.Main();
        }

        private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args)
        {
            //We dont' care about System Assemblies and so on...
            //if (!args.Name.ToLower().StartsWith("wpfcontrol")) return null;

            Assembly thisAssembly = Assembly.GetExecutingAssembly();

            //Get the Name of the AssemblyFile
            var name = args.Name.Substring(0, args.Name.IndexOf(',')) + ".dll";

            //Load form Embedded Resources - This Function is not called if the Assembly is in the Application Folder
            var resources = thisAssembly.GetManifestResourceNames().Where(s => s.EndsWith(name));
            if (resources.Count() > 0)
            {
                var resourceName = resources.First();
                using (Stream stream = thisAssembly.GetManifestResourceStream(resourceName))
                {
                    if (stream == null) return null;
                    var block = new byte[stream.Length];
                    stream.Read(block, 0, block.Length);
                    return Assembly.Load(block);
                }
            }
            return null;
        }
    }

我的问题是Fluent Ribbon控件无法找到任何风格,但我在我的app.xaml

My problem is that the Fluent Ribbon Control cant find any style, but i settled it with them code in my app.xaml

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Office2010/Silver.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

我有这个解决方案的第二个问题是我无法连接到我的数据库(SQL Express)与我的程序,当我启动它没有Visual Studio。

The second problem that i have with this solution is that i cant connect to my database(SQL Express) with my program when i start it without Visual Studio.

当我拥有流畅的相同文件夹时,它只是工作,因为它不会从嵌入式引用的流利程序加载它。而流利的人也可以找到这样的风格。

When i have the fluent in the same folder it just works, because then it don't load it from the embedded referenced fluent. And the Fluent can find the style too so.

有没有人将与dll /流利的合并到main.exe中有类似的经验,可以告诉我你是如何解决的

Has anyone had similar experience with the merging of dll/fluent into the main.exe and can you show me how you solved it?

推荐答案

使用Fody.Costura,对我有用(我也使用Fluent)。

Use Fody.Costura instead, that works for me (and I also use Fluent).

https://github.com/Fody/Costura

其中一个重要的事情是让你的应用知道它必须加载程序集。我有时会强制加载,这在你的应用程序启动中:

One of the important things is to let your app know that it must load the assembly. What I sometimes do to force the loading is this in your app startup:

Console.WriteLine(typeof(Fluent).Name);

Console.WriteLine(typeof(Fluent).Name);

这篇关于合并到main.exe之后的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆