title: C# .Net App On Windows XP Fails Shell32 Code for Renaming Shortcut
body: <p>I have a situation where I have a windows Desktop APP in .Net C# that must on both Windows 7 and Windows XP rename a shortcut.  I have it working in Windows 7 but on XP this fails.</p>
  
  <p>.Net 4.0 Client Profile and Extended is installed on XP and all other parts of the applciation are functioning on XP.  The project has a reference Interop.Shell32 (MIcrosoft Shell Controls and Automation through COM Interop rahter than pinvoke) and the code is simply the following:</p>
  
  <pre><code>var shl = new Shell32.Shell();
  argStrLnkPath = System.IO.Path.GetFullPath(argStrLnkPath);
  var dir = shl.NameSpace(System.IO.Path.GetDirectoryName(argStrLnkPath));
  var itm = dir.Items().Item(System.IO.Path.GetFileName(argStrLnkPath));
  itm.Name = "My Shortcut Name";
  </code></pre>
  
  <p>The above works in 7 but not XP. The following versions of the Shell32.dll exist:</p>
  
  <p>Win7 Shell32.dll version 6.1.7601
  WinXP Shell32.dll version 6.00.29.6242</p>
  
  <p>When I spy the XP shell32dll in the object browser, the same objects exist, so the functionalty should be there (unless I'm not seeing something important).</p>
  
  <p>My project is set to build as x86 platform for both machines.  For the reference, I have tried the Embed Interop Types as True and also copy local as False.   </p>
  
  <p>I have an msi installer but is there something I need to do on the target XP machine? And should I copy Local?  Any ideas on the propper way to get this working?  </p>
  
  <p>I have run the code on that XP Machine and receive the following from teh Event Viewer:</p>
  
  <p>Framework Version: v4.0.30319
  Description: The process was terminated due to an unhandled exception.
  Exception Info: System.InvalidCastException</p>
  
  <p><strong>Embed Interop Types for Reference = True</strong>: The stackTrace for this error is:
  Unable to cast COM object of type 'System.__ComObject' to interface type 'Shell3
  2.Shell'. This operation failed because the QueryInterface call on the COM compo
  nent for the interface with IID '{866738B9-6CF2-4DE8-8767-F794EBE74F4E}' failed
  due to the following error: No such interface supported (Exception from HRESULT:
   0x80004002 (E_NOINTERFACE)).</p>
  
  <p><strong>Embed Interop Types for Reference = False</strong>: The stackTrace for this error is:
  Framework Version: v4.0.30319  Description: The process was terminated due to an unhandled exception.  Exception Info: System.IO.FileNotFoundException</p>