IWshRuntimeLibrary Error
Posted: Thu Sep 29, 2011 7:50 pm
I pulled a solution using Subversion from a different branch that was developed on another PC. The solution runs fine on other machines but when I try to run a specific recording I get the following error:
The specific code being referenced is below. Any ideas what the problem is? ThanksCould 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.
Code: Select all
/*
* Launch Desktop shortcuts by name 'appName'
*/
[DllImport("shfolder.dll", CharSet = CharSet.Auto)]
private static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath);
public void LaunchShortcut(string appName)
{
//Get the public desktop
const int MAX_PATH = 260;
const int CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019;
StringBuilder sbPath = new StringBuilder(MAX_PATH);
SHGetFolderPath(IntPtr.Zero, CSIDL_COMMON_DESKTOPDIRECTORY, IntPtr.Zero, 0, sbPath);
string strDesktop = sbPath.ToString() + "\\" + appName + ".lnk";
//Start a process that will launch the shortcut
//This is not creating a short cut, its actually, opening the shortcut
WshShell Wshell = new WshShell();
IWshRuntimeLibrary.IWshShortcut shortc = (IWshRuntimeLibrary.IWshShortcut)Wshell.CreateShortcut(strDesktop);
if(shortc!=null)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName=(string)shortc.TargetPath;
proc.StartInfo.Arguments = (string)shortc.Arguments;
proc.StartInfo.WorkingDirectory = (string)shortc.WorkingDirectory;
proc.Start();
}
}