Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///C:\MyPr
ojects\ProxyService\ProxyInstaller\bin\Debug\ProxyInstaller.exe' or one of its d
ependencies. This assembly is built by a runtime newer than the currently loaded
runtime and cannot be loaded..
我用命令行安装Windows服务,出现以上错误:
我安装的过程如下:
1。运行--〉cmd:打开cmd命令框
2。在命令行里定位到InstallUtil.exe所在的位置
InstallUtil.exe 默认的安装位置是在C:/Windows/Microsoft.NET/Framework/v2.0.50727里面,所以你要在cmd里通过cd定位到该位置(cd C:/Windows/Microsoft.NET/Framework/v2.0.50727)
3。操作命令:
1). 安装服务命令:在命令行里输入下面的命令:
InstallUtil.exe Path/WinServiceName.exe
其中Path表示ServiceName.exe所在的位置,回车即可
安装失败的原因是:我服务是用.net 4.0写的,不能用.net 2.0的InstallUtil去安装服务,所以,应该用C:\Windows\Microsoft.NET\Framework\v4.0.30319文件夹下的InstallUtil去安装服务。
Not that way round, no. The .NET 4 CLR can load .NET 2 assemblies (usually - there are a few exceptions for mixed-mode assemblies, IIRC), but not vice versa.
You'll either have to upgrade the .NET 2 project to .NET 4, or downgrade the .NET 4 project to .NET 3.5 (or earlier).
|