不同版本的ClickOnce应用程序由于缺少原始UI.exe文件而导致崩溃

如何解决不同版本的ClickOnce应用程序由于缺少原始UI.exe文件而导致崩溃

我对ClickOnce版本有疑问:

  • 我们需要在每台计算机上通过ClickOnce安装三个版本的程序,每个版本具有不同的设置:生产,试验和测试
  • 我们要做的是使用一个自编程的发布管理器,该管理器使用MSBuild将每个版本部署在不同的网络驱动器位置中
  • 可以很好地安装每个版本,但是程序运行时会崩溃。
  • 运行MSBuild时ApplicationName更改了,我发现在应用程序名称更改为例如的同时,该应用程序仍在寻找原始的UI.exe。 UITest.exe
  • 如果我将UI.exe复制到安装文件夹中,然后运行UITest.exe,则程序将正常运行。

我想念什么?我该如何摆脱对原始UI.exe的需求?

背景信息:

为了能够通过MSBuild发行三个不同的版本,我们使用了一个附加的“ .target”文件,该文件在如下所示的构建属性组之后在UI.csproj中实现:

<Import Project="CustomBuild.targets" />

CustomBuild.targets文件如下:

<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PublishType>none</PublishType>
  </PropertyGroup>
  <Choose>
    <When Condition="'$(PublishType)' == 'production'">
      <PropertyGroup>
        <PublishUrl>\\netapp1\users\ClickOnce\Production\</PublishUrl>
        <InstallUrl>\\netapp1\users\ClickOnce\Production\</InstallUrl> 
        <PublishDir>\\netapp1\users\ClickOnce\Production\</PublishDir> 
        <ProductName>UI Production</ProductName>
        <AssemblyName>UIProd</AssemblyName> -- AssemblyName is changed here
        <UIExchangeSettingsPath>..\_UIExchangeSettings\Prod</UIExchangeSettingsPath>
    </PropertyGroup>
    </When>
    <When Condition=" '$(PublishType)' == 'pilot' ">
      <PropertyGroup>
        <PublishUrl>\\netapp1\users\ClickOnce\Pilot\</PublishUrl>
        <InstallUrl>\\netapp1\users\ClickOnce\Pilot\</InstallUrl>
        <PublishDir>\\netapp1\users\ClickOnce\Pilot\</PublishDir> 
        <ProductName>UI Pilot</ProductName>
        <AssemblyName>UIPilot</AssemblyName> -- AssemblyName is changed here
        <UIExchangeSettingsPath>..\_UIExchangeSettings\Pilot</UIExchangeSettingsPath>
      </PropertyGroup>
    </When>
    <When Condition=" '$(PublishType)' == 'test' ">
      <PropertyGroup>
        <PublishUrl>\\netapp1\users\ClickOnce\Test\</PublishUrl>
        <InstallUrl>\\netapp1\users\ClickOnce\Test\</InstallUrl>
        <PublishDir>\\netapp1\users\ClickOnce\Test\</PublishDir> 
        <ProductName>UI Test</ProductName>
        <AssemblyName>UITest</AssemblyName> -- AssemblyName is changed here
        <UIExchangeSettingsPath>..\_UIExchangeSettings\Test</UIExchangeSettingsPath>
      </PropertyGroup>
    </When>
  </Choose>
</Project>

然后在这样的批处理文件中调用MSBuild流程:

@echo off

set branch=%1
set publishtype=%2

echo Rebuilding UI project and publishing as new %publishtype% version...
>output.txt (
  "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin\MSBuild.EXE" "C:\Projects\%branch%\UI" /p:SolutionDir="C:\Projects\%branch%\\" /p:PlatformTarget=x86 /p:Configuration=Release /p:PublishType=%publishtype% /t:rebuild /t:publish 
)

运行已安装的程序时,它们会崩溃并在Windows事件日志中显示以下异常:

Log Name:      Application
Source:        .NET Runtime
Date:          11.11.2020 10:02:58
Event ID:      1026
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      vw8-te-012.HOPPE-BMT.intranet
Description:
Application: UIProd.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
   at System.Reflection.RuntimeAssembly._nLoad(System.Reflection.AssemblyName,System.String,System.Security.Policy.Evidence,System.Reflection.RuntimeAssembly,System.Threading.StackCrawlMark ByRef,IntPtr,Boolean,Boolean)
   at System.Reflection.RuntimeAssembly.nLoad(System.Reflection.AssemblyName,Boolean)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName,Boolean)
   at System.Reflection.Assembly.Load(System.Reflection.AssemblyName)
   at System.Windows.Navigation.BaseUriHelper.GetLoadedAssembly(System.String,System.String)
   at MS.Internal.AppModel.ResourceContainer.GetResourceManagerWrapper(System.Uri,System.String ByRef,Boolean ByRef)
   at MS.Internal.AppModel.ResourceContainer.GetPartCore(System.Uri)
   at System.IO.Packaging.Package.GetPartHelper(System.Uri)
   at System.IO.Packaging.Package.GetPart(System.Uri)
   at System.IO.Packaging.PackWebResponse+CachedResponse.GetResponseStream()
   at System.IO.Packaging.PackWebResponse.GetResponseStream()
   at System.IO.Packaging.PackWebResponse.get_ContentType()
   at MS.Internal.WpfWebRequestHelper.GetContentType(System.Net.WebResponse)
   at MS.Internal.WpfWebRequestHelper.GetResponseStream(System.Net.WebRequest,MS.Internal.ContentType ByRef)
   at System.Windows.ResourceDictionary.set_Source(System.Uri)
   at System.Windows.Baml2006.WpfSharedBamlSchemaContext+<>c.<Create_BamlProperty_ResourceDictionary_Source>b__342_0(System.Object,System.Object)
   at System.Windows.Baml2006.WpfKnownMemberInvoker.SetValue(System.Object,System.Object)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(System.Xaml.XamlMember,System.Object,System.Object)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(System.Object,System.Xaml.XamlMember,System.Object)

Exception Info: System.Windows.Markup.XamlParseException
   at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader,System.Xaml.IXamlObjectWriterFactory,System.Xaml.XamlObjectWriterSettings,System.Uri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader,System.Xaml.Permissions.XamlAccessLevel,System.Uri)
   at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream,System.Windows.Markup.ParserContext,Boolean)
   at System.Windows.Application.LoadComponent(System.Object,System.Uri)
   at UI.App.InitializeComponent()
   at UI.App.Main()

Log Name:      Application
Source:        Application Error
Date:          11.11.2020 10:02:58
Event ID:      1000
Task Category: (100)
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      vw8-te-012.HOPPE-BMT.intranet
Description:
Faulting application name: UIProd.exe,version: 1.0.0.0,time stamp: 0x5faba858
Faulting module name: KERNELBASE.dll,version: 6.3.9600.17031,time stamp: 0x53088860
Exception code: 0xe0434352
Fault offset: 0x00014dbd
Faulting process ID: 0x3594
Faulting application start time: 0x01d6b80972f79f7d
Faulting application path: C:\Users\c.nowottny\AppData\Local\Apps\2.0\XNQORKVG.2DT\5A4N7BAY.11G\uipr..tion_e9badd1d426758be_0001.0001_0a1650216431b128\UIProd.exe
Faulting module path: C:\Windows\SYSTEM32\KERNELBASE.dll
Report ID: b1090c1f-23fc-11eb-82ef-0050568fb707
Faulting package full name: 
Faulting package-relative application ID: 

解决方法

原来是对导致问题的App.xaml中的资源字典的引用。

错误的实现:

<ResourceDictionary Source="pack://application:,/UI;component/Resources/PlcBuildResources.xaml" />

正确的实现:

<ResourceDictionary Source="../Resources/PlcBuildResources.xaml"/>

经验教训::使用引用中的程序集名称引用资源字典或其他文件时要小心。如果像我这样在通过MSBuild进行构建时更改了程序集名称,则将找不到引用的文件并导致应用程序崩溃。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-