使用 .NetZ 和 WPF 会导致 System.IO.IOException [英] Using .NetZ and WPF causes System.IO.IOException
问题描述
我的目标是能够通过命令行或 Visual Studio 中的完整内置程序为 C# 应用程序和库(首选 WPF)使用任何打包程序.
My aim is to be able to use any packer for C# applications and libraries (preferring WPF) via command line or full build-in at Visual Studio.
我遇到了 .NetZ (http://madebits.com/netz/),它非常简洁并且运行良好,直到我使用 WPF 应用程序对其进行了测试:
I came accross .NetZ (http://madebits.com/netz/) that is pretty neat and worked pretty well until I tested it with a WPF application:
PackageExample.Program -> C:\Users\[username]\Documents\Visual Studio
2012\Projects\PackageExample\PackageExample.Program\bin\Debug\PackageExample.Program.exe
COMMAND: packcompress\netz-bin-40\netz.exe -o PackageExample.Program\bin\Debug\Packed -pl
anycpu -s -z PackageExample.Program\bin\Debug\PackageExample.Program.exe
"PackageExample.Program\bin\Debug\*.dll" -d:@ -v
__________________________________________
| |
| .NETZ - .NET Executables Compressor |
| Copyright (C) 2004-2013 Vasian Cepa |
| [v0.4.8] http://madebits.com |
|__________________________________________|
PE subsystem : GUI
.NET Runtime : 4.0.30319.18052
Output directory: C:\Users\[username]\Documents\Visual Studio
2012\Projects\PackageExample\PackageExample.Program\bin\Debug\Packed
RID: zip.dll
Added : C:\Users\[username]\Documents\Visual Studio
2012\Projects\PackageExample\packcompress\netz-bin-40\zip.dll [65536 byte(s) ~ 64KB]
Processing : 3 file(s)
1| C:\Users\[username]\Documents\Visual Studio
2012\Projects\PackageExample\PackageExample.Program\bin\Debug\PackageExample.Program.exe
[255488 byte(s) ~ 249KB] -> [130850 byte(s) ~ 127KB] - 49%
RID: A6C24BF5-3690-4982-887E-11E1B159B249
2| C:\Users\[username]\Documents\Visual Studio
2012\Projects\PackageExample\PackageExample.Program\bin\Debug\PackageExample.Lib1.dll
[4096 byte(s) ~ 4KB] -> [1577 byte(s) ~ 1KB] - 62%
RID: PackageExample.Lib1!2!1Version=1.0.0.0!2!1!4=neutral!2!1PublicKeyToken=null
3| C:\Users\[username]\Documents\Visual Studio
2012\Projects\PackageExample\PackageExample.Program\bin\Debug\PackageExample.Lib2.dll
[4608 byte(s) ~ 4KB] -> [1617 byte(s) ~ 1KB] - 65%
RID: PackageExample.Lib2!2!1Version=1.0.0.0!2!1!4=neutral!2!1PublicKeyToken=null
Done [00:00:00.300]
打包的应用程序抛出这个:http://i.imagebanana.com/img/251ygj82/Unbenannt.PNG(找不到资源 mainwindow.xaml.)
The packed app throws this: http://i.imagebanana.com/img/251ygj82/Unbenannt.PNG (The ressource mainwindow.xaml cannot be found.)
问题似乎是 xaml .NetZ 混淆,但我发现有些人在互联网上使用它,但我没有得到任何问题的解决方案.
The problem seems to be the xaml .NetZ confuses, but I found some people who got it working on the internet, but I do not get any problem solution.
在这种情况下你能帮我吗?
Are you able to help me in this case?
附加信息:值得一提的是,我什至在 .NET 3.5 WPF 应用程序上使用 .NET 2.0 .NetZ 构建进行了尝试.
Additional information: It might be interesting to mention I even tried this with the .NET 2.0 .NetZ build on a .NET 3.5 WPF application.
推荐答案
我在使用 NetZ 将 WPF 4.0 exe 和 DLL 压缩为单个 exe 时也遇到了问题.我的 app.xml.cs 将开始运行,但随后会抛出 NotImplementedException 类型的 UnhandledException:Baml2006SchemaContext.ResolveBamlType ...
I also had problems using NetZ to compress an WPF 4.0 exe and DLLs into a single exe. My app.xml.cs would start to run, but then an UnhandledException of type NotImplementedException would be thrown: Baml2006SchemaContext.ResolveBamlType ...
为了解决这个问题,我运行 fuslogvw.exe 来查看程序集绑定错误,并发现 GalaSoft.MvvmLight.Wpf4.dll 无法从 Netz 打包的程序集中加载.然后我切换到从源代码编译的 NetZ.exe 并再次尝试.经过反复试验,我发现如果我重新编译和 NetZ 打包应用程序,它有时会开始工作.再次重新编译主应用程序,NetZ 生成一个失败的应用程序.换句话说,有些事情是间歇性的.对于不太好的消息,我们深表歉意——要么尝试另一种打包方案,要么在多次构建中反复尝试 NetZ,直到找到一个可行的方案.
To troubleshoot this, I ran fuslogvw.exe to see assembly binding errors, and discovered that GalaSoft.MvvmLight.Wpf4.dll was failing to load from the Netz-packed assembly. I then switched to NetZ.exe compiled from source and tried again. After repeated experimentation, I see that if I recompile and NetZ-pack the app, it sometimes starts working. Recompile again the main app again, and NetZ produces a failing app. In other words, something is intermittent. Sorry for the not-so good news - either try another packing scheme, or try NetZ repeatedly on many builds, until you find a working one.
这篇关于使用 .NetZ 和 WPF 会导致 System.IO.IOException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!