2011-03-11 60 views
1

我有一个使用VS2008安装程序安装的.NET 3.5 Windows服务&部署项目。它有一个自定义安装操作。这个服务的安装很好,直到我最近升级到VS2010/.NET 4.现在,当我升级到新版本时,我得到安装错误:“错误1001 ... BadImageFormatException:无法加载文件或程序集...此程序集由比当前加载的运行时更新的运行时构建......“。如果我卸载以前的版本,然后安装新版本,一切正常......没有错误。正在我的开发机器上执行安装,因此.NET 4框架已经在那里。.NET 4 Windows服务安装升级错误

我启用了Fusion日志记录,发现了一个错误文件(见下文)。服务“ServerService.exe”正在由.NET 2.0框架加载,但我不确定这是为什么。安装中的其他文件由4.0框架加载。有没有人有任何建议如何解决这个问题或我如何进一步调查?

该项目面向.NET 4.0框架和我的app.config包含以下行:

<startup useLegacyV2RuntimeActivationPolicy="true"> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 
    </startup> 

感谢,
史蒂夫


融合日志:

Assembly Binder Log Entry (3/11/2011 @ 2:44:03 PM) 

The operation failed. 
Bind result: hr = 0x8013101b. No description available. 

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll 
Running under executable C:\Windows\syswow64\MsiExec.exe 
--- A detailed error log follows. 

=== Pre-bind state information === 
LOG: User = NT AUTHORITY\SYSTEM 
LOG: Where-ref bind. Location = C:\Program Files (x86)\Server\ServerService.exe 
LOG: Appbase = file:///C:/Windows/syswow64/ 
LOG: Initial PrivatePath = NULL 
LOG: Dynamic Base = NULL 
LOG: Cache Base = NULL 
LOG: AppName = NULL 
Calling assembly : (Unknown). 
===<br> 
LOG: This bind starts in LoadFrom load context. 
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load(). 
LOG: No application configuration file found. 
LOG: Using host configuration file: C:\Users\Steve\AppData\Local\Temp\CFG94A5.tmp 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config. 
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Server/ServerService.exe. 
LOG: Assembly download was successful. Attempting setup of file: C:\Program Files (x86)\Server\ServerService.exe 
LOG: Entering run-from-source setup phase. 
ERR: Error extracting manifest import from file (hr = 0x8013101b). 
ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated.** 
+0

看看这个问题上SO:http://stackoverflow.com/questions/3953063/how-to-force-an-application-to-use-net-3-5-or-above – kd7 2011-03-11 20:31:27

+0

卸载自定义操作正在运行旧应用程序。这可能是问题的一部分。还有另一件要检查的是MSI的版本号更改,并且程序集版本是否在exe/dll文件中更改? (如果它们是相同的版本,它们可能不会被替换,因此旧文件仍然存在) – randbrown 2011-03-11 21:21:41

+0

是的,我倾向于同意,看起来卸载自定义操作似乎是问题的根源。不幸的是,我不知道如何超越我所处的位置来进一步解决问题。安装项目的版本属性增加(与ProductCode属性一起)。 – Steve 2011-03-11 21:31:32

回答

0

当我删除自定义操作从我的应用程序,升级工作得很好,所以我想我已经指出了问题的根源。

+0

如果这是该问题的正确答案,则可以继续并将其标记为答案。这样做没有任何处罚,并且它不会显示在未回答问题的列表中。 – 2011-05-11 12:27:54

0

我有一个非托管的C++ EXE通过COM调用.NET DLL。

这里需要提到的是什么的<startup>...块,上面列出的,需要被添加到foo.exe.config,以及app.config(其中foo.exe是你的可执行文件)。配置文件需要存在于安装目录中。

我得到了完全相同的错误,因为FUSLOGVW显示Windows正在加载.NET 2框架,虽然我正在编译.NET 4.我已经格式化了我的app.config,但这还不够。