2014-09-05 35 views
1

上运行我编译应用程序使用的.NET Framework 4,因为我需要这在XP和Server 2003不支持.NET框架4.5的工作。问题是,现在运行良好的XP和2003点的服务器,但不是我的服务器上2012 Server 2012中具有.NET 4.5,从我读过.NET 4.5是在.NET 4应用.NET 4的框架编译不会Server 2012的

它下面的错误向后兼容我收到我的2012服务器上:如果您单击继续,应用程序将忽略此错误并尝试继续


未处理的异常发生在您的应用程序。如果您单击退出,应用程序将立即关闭。

该系统找不到指定的文件。

详情:

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box. 

************** Exception Text ************** 
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified 
    at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) 
    at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) 
    at MyApplication.Form1.DirectoryExporter_Click(Object sender, EventArgs e) 
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
    at System.Windows.Forms.Control.WndProc(Message& m) 
    at System.Windows.Forms.ButtonBase.WndProc(Message& m) 
    at System.Windows.Forms.Button.WndProc(Message& m) 
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 


************** Loaded Assemblies ************** 
mscorlib 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.0.30319.18449 built by: FX451RTMGDR 
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll 
---------------------------------------- 
MyApplication 
    Assembly Version: 1.0.0.0 
    Win32 Version: 1.0.0.0 
    CodeBase: file:///C:/Users/administrator.DM/Desktop/MyApplication.exe 
---------------------------------------- 
System.Windows.Forms 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll 
---------------------------------------- 
System.Drawing 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll 
---------------------------------------- 
System 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL 
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll 
---------------------------------------- 

************** JIT Debugging ************** 
To enable just-in-time (JIT) debugging, the .config file for this 
application or computer (machine.config) must have the 
jitDebugging value set in the system.windows.forms section. 
The application must also be compiled with debugging 
enabled. 

For example: 

<configuration> 
    <system.windows.forms jitDebugging="true" /> 
</configuration> 

When JIT debugging is enabled, any unhandled exception 
will be sent to the JIT debugger registered on the computer 
rather than be handled by this dialog box. 

这里是被称为此时代码:

public string get_regValue(string userroot, string subkey, string keyname, string app) 
     { 
      string userRoot = userroot; 
      string subKey = subkey; 
      string keyName = userRoot + "\\" + subKey; 

      string regValue = (string)Registry.GetValue(keyName, keyname, null); 
      regValue = regValue + app; 

      return regValue; 
     } 

     private void DirectoryExporter_Click(object sender, EventArgs e) 
     { 
      // Button to Launch the Directory Exporter 
      string regKey; 
      RegistryKey openKey = Registry.LocalMachine.OpenSubKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Dell"); 
      // Checks for key, if null (empty) get 32 bit key 
      if (openKey == null) 
      { 
       // 32 bit key 
       regKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Dell"; 
      } 
      else 
      { 
       // 64 bit key 
       regKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Dell"; 
      } 

      var regvalue = get_regValue(regKey, "Migrator for GroupWise", "AdminInstallDir", "gwdirapp.exe"); 
      Process.Start(@regvalue); 
     } 
+1

@Cory:不,你不应该需要。 .NET 4.5是一个in-place升级为.NET 4,所以它应该是罚款... – 2014-09-05 13:34:13

+0

我同意和服务器2012年,你甚至不能安装.NET 4,因为它是操作系统 – JRMackz 2014-09-05 14:14:16

回答

4

我强烈怀疑这无关,与.NET的版本,正在使用。毕竟,从堆栈跟踪,你可以清楚地看到你的代码执行:

at MyApplication.Form1.DirectoryExporter_Click(Object sender, EventArgs e) 

我怀疑,问题是权限之一 - 无论你正在试图做在Windows Server 2012中失败由于它运行在更加锁定的环境中。

或者,它可能是你试图启动您的开发机器存在一个过程,而不是在服务器上。如果没有看到代码,我们无法确定 - 但您应该仔细查看DirectoryExporter_Click中正在执行的操作,特别是在拨打Process.Start时。检查您尝试运行的可执行文件,然后检查它是否存在于服务器上,并且您正在运行的用户有权执行它。

+0

此服务器的一部分应用程序存在的位置。如果我在.NET 4.5中编译它,它可以在这台服务器上运行,不会有其他更改,但是它不会在我的旧机器上运行 – JRMackz 2014-09-05 13:47:03

+1

@JRMackz很可能您尝试启动的进程的路径在服务器上不同。异常消息表示无法找到该文件。它或者不在你期望的地方。 – Trevor 2014-09-05 13:52:28

+0

@JRMackz:这听起来对我来说不太可能,因为你收到的例外。这将有助于如果你愿意告诉我们,虽然你的代码... – 2014-09-05 13:55:51

0

我通过编辑代码解决了这个,如下图所示:

public string get_regValue(string userroot, string subkey, string keyname, string app) 
{ 
    string userRoot = userroot; 
    string subKey = subkey; 
    string keyName = userRoot + "\\" + subKey; 

    string regValue = (string)Registry.GetValue(keyName, keyname, null); 
    regValue = regValue + app; 

    return regValue; 
} 

private void DirectoryExporter_Click(object sender, EventArgs e) 
{ 
    // Button to Launch the Directory Exporter 
    string regKey; 
    RegistryKey openKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\\Wow6432Node\\Dell"); 
    // Checks for key, if null (empty) get 32 bit key 

    if (openKey == null) 
    { 
     // 32 bit key 
     regKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Dell"; 
    } 
    else 
    { 
     // 64 bit key 
     regKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Dell";     
    } 

    var regvalue = get_regValue(regKey, "Migrator for GroupWise", "AdminInstallDir", "gwdirapp.exe"); 
    Process.Start(regvalue); 
+0

只是为了清楚起见,从'Registry.LocalMachine.OpenSubKey'调用中删除了'HKEY_LOCAL_MACHINE'。 – 2015-03-11 17:02:59

相关问题