如果调试文件夹的其余部分可用,但我的 EXE 运行良好,但不是独立的

My EXE runs fine if it has the rest of the debug folder available, but not standalone

我有一个 WPF 应用程序,我想将其部署为独立的应用程序,以便用户可以从网站下载它 运行 而无需安装。

它 运行 没问题(从任何机器),只要它包含调试文件夹中的所有文件:

如果我尝试 运行 只是 EXE 而没有其他文件,如果崩溃。有什么方法可以将这些文件精简到 EXE 中,使其 运行 独立?

(表格上有一张背景图片,但它被设置为 Build Action = Resource,所以我认为这不是问题所在。此外,不必按顺序将图片复制到另一台机器运行,就是上面显示的文件。) 事件日志中的错误是:

Faulting application name: AMBootstrapper.exe, version: 1.0.0.0, time stamp: 0x572caffc
Faulting module name: KERNELBASE.dll, version: 10.0.10586.162, time stamp: 0x56cd55ab
Exception code: 0xe0434352

和:

Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.

编辑:经过更多测试后,我可以删除大部分文件,但我不能删除的是 AMBootStrapper.exe.config

根据@BenJackson 的说法,问题是 WCF 服务详细信息在应用程序配置中。

解决方案是从 app.config 中删除它:

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IService" allowCookies="true" maxReceivedMessageSize="184320" maxBufferPoolSize="184320" >
                <security mode="Transport">
                    <transport clientCredentialType="None" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://svc.myserver.com/MyService/Service.svc/Service.svc"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService"
            contract="MyService.IService" name="WSHttpBinding_IService" />
    </client>
</system.serviceModel>

并在代码中替换为:

WSHttpBinding binding = new WSHttpBinding();
binding.AllowCookies = true;
binding.MaxBufferPoolSize = 184320;
binding.MaxReceivedMessageSize = 183420;
binding.Security.Mode = SecurityMode.Transport;

EndpointAddress address = new EndpointAddress("https://svc.myserver.com/MyService/Service.svc/Service.svc");

MyService.MyClient c = new MyService.MyClient(binding, address);