我知道有很多人回复此话题,但我对这个回信中示例代码不工作的每一个.dll文件合并C#DLL的成.EXE
我以前this例子。
public App()
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ResolveAssembly);
}
static Assembly ResolveAssembly(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;
}
当我创建了一个小的程序,只有一个窗口和一个比唐它有工作,但我的“大” DLL它说好的工作。 “big”dll的设置与我的小程序中的设置相同。
我无法想象它为什么有时有效,有时它不工作。我也用ICSharp.AvalonEdit.dll测试过,不成功。
任何人都可以想象错误在哪里?
编辑1
当我开始我的程序它说,它不能找到我的DLL。
编辑2
我想我得到了我的问题的核心。如果其中一个dll的,我想要合并包含对其他dll的引用,则会发生这种情况,例如:FileNotFoundException
。难道有人知道如何加载当我使用从吉日波拉塞克代码它适用于一些/还加了内部所需的dll的
编辑3
。我Fluent显示错误“请附上与风格的ResourceDictionary但我不得不在已经这样做了我的App.xaml
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Office2010/Silver.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
使用你的代码后,我遇到了一些麻烦。请显示[这里](http://stackoverflow.com/questions/18328483/problems-after-merging-fluent-into-main-exe) –