我运行一个.NET 2.0可执行.com扩展名从一个命令行收到以下错误:
I'm running a .NET 2.0 executable with a .com extension from a command line and receiving the following error:
System.BadImageFormatException : The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)
我是pretty的确保它试图加载从.NET 2.0全局程序集缓存的DLL。
I'm pretty sure it's trying to load a DLL from the .NET 2.0 Global Assembly Cache.
我只得到与.NET 4.0 / Visual Studio 2010的机器上安装这个错误,所以我使用了错误的.NET Framework版本运行假设它。 关于如何确认这个假设任何想法?
I only get this error on machines with .net 4.0 / visual studio 2010 installed, so I'm assuming its using the wrong .net framework version to run. Any ideas on how to confirm this assumption?
或者是有办法规定程序使用.NET 2运行时,而不是.NET 4运行.com文件?
or is there a way to specify the program to use .net 2 runtime instead of .net 4 to run the .com file?
如果只有.NET 4.0框架安装并要运行的应用程序构建/使用.NET 2.0,则需要通知.NET 4.0框架该应用程序需要.NET 2.0运行时。这是通过使用配置文件以下条目。
If only the .NET 4.0 Framework is installed and you want to run an application build for/with .NET 2.0, you need to inform the .NET 4.0 Framework that the application requires the .NET 2.0 Runtime. That is done using a configuration file with the following entries.
必要的属性设置为 useLegacyV2RuntimeActivationPolicy
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v2.0.50727"/>
<supportedRuntime version="v4.0.30319"/>
</startup>
</configuration>