title: Not able to use Windows Script Host Object Model in .net 3.5 project
body: <p>I have a C# console application (.Net version 3.5) with following code</p>
  
  <pre><code>static void Main(string[] args)
  {
      IWshRuntimeLibrary.WshNetwork aNetworkInstance = new IWshRuntimeLibrary.WshNetwork();
  }
  </code></pre>
  
  <p>When I run the program it is throwing following error.</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.BadImageFormatException'
    occurred in Microsoft.VisualStudio.HostingProcess.Utilities.dll</p>
    
    <p>Additional information: Could not load file or assembly
    'Interop.IWshRuntimeLibrary, Version=1.0.0.0, Culture=neutral,
    PublicKeyToken=null' or one of its dependencies. This assembly is
    built by a runtime newer than the currently loaded runtime and cannot
    be loaded.</p>
  </blockquote>
  
  <p>I found that the generated interop file Interop.IWshRuntimeLibrary.dll is refering to 4.0.0.0 version of mscorelib.</p>
  
  <pre><code>.assembly extern mscorlib
  {
    .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
    .ver 4:0:0:0
  }
  </code></pre>
  
  <p>If I change the .net version of the project to 4, then it is working fine. Any idea why the Interop.IWshRuntimeLibrary.dll is always refering to version 4 of mscorlib even when I select .net 3.5 in the project?</p>
  
  <p>PS: The same program is working in other systems. The issue is only in one system.</p>
  
  <blockquote>
    <p>EDIT: Following are the steps I have done.</p>
  </blockquote>
  
  <p>Create a C# Console application (.Net version 3.5).
  Add referece to Windows Scribt Host Object model</p>
  
  <p>Add following line in the Main()</p>
  
  <pre><code>static void Main(string[] args)
  {
      IWshRuntimeLibrary.WshNetwork aNetworkInstance = new IWshRuntimeLibrary.WshNetwork();
  }
  </code></pre>
  
  <p>When I run the application, it is throwing following exception.</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.BadImageFormatException'
    occurred in mscorlib.dll</p>
    
    <p>Additional information: Could not load file or assembly
    'Interop.IWshRuntimeLibrary, Version=1.0.0.0, Culture=neutral,
    PublicKeyToken=null' or one of its dependencies. This assembly is
    built by a runtime newer than the currently loaded runtime and cannot
    be loaded.</p>
  </blockquote>
  
  <p>I am able to build and run the project in other machines.
  If I copy the Interop.IWshRuntimeLibrary.dll generated in another machine, then also the program is running in my machine.
  But I am not able to run the program with the Interop.IWshRuntimeLibrary.dll generated in my machine.</p>
  
  <p>I know it is a strange problem. May be I have to reformat my hard disk as you suggested by Hans Passant :(</p>
  
  <blockquote>
    <p>EDIT: Output of the detailed build</p>
  </blockquote>
  
  <pre><code>1&gt;  C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\TlbImp.exe C:\Windows\SysWOW64\wshom.ocx /namespace:IWshRuntimeLibrary /machine:X86 /out:obj\x86\Release\Interop.IWshRuntimeLibrary.dll /sysarray /transform:DispRet /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /reference:C:\WINDOWS\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll 
  1&gt;  Microsoft (R) .NET Framework Type Library to Assembly Converter 4.0.30319.33440
  1&gt;  Copyright (C) Microsoft Corporation.  All rights reserved.
  1&gt;  
  1&gt;  TlbImp : Type library imported to C:\Users\IC007121\Documents\Visual Studio 2013\Projects\wsherrortest\wsherrortest\obj\x86\Release\Interop.IWshRuntimeLibrary.dll
  1&gt;  Resolved COM reference for item "IWshRuntimeLibrary": "obj\x86\Release\Interop.IWshRuntimeLibrary.dll".
  </code></pre>