在Vista上使用Visual Studio 2005 C#编写的代码无法在使用Visual Studio 2010 C#的新Windows 7 PC上运行

用户名

今天,我得到了这款新的Windows 7 64位PC。有一个应用程序是使用Visual Studio 2005 C#在Vista 64位上编写的,必须转移到这台新PC上。但是,我尝试使用visual studio 2010 c#express运行它,然后弹出此错误:

Unhandled exception has occured in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit. the application will close immediately.
InvalidArgument=Value of "2" is not valid for "SelectedIndex".
Parameter name: Selected Index
***************Exception Text********************
System.ArgumentOutOfRangeException:InvalidArgument=Value of "2" is not valid for "SelectedIndex"
Parameter name: Selected Index
    at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32value)
    at CameraTestApp.PTCMeasurement.PTCMeasurement_Load(Object sender, EventArgs e) in C:.....
    at System.Windows.Forms.Form.OnLoad(EventArgs e)
    at System.Windows.Forms.Form.OnCreateControl()
    at System.Windows.Forms.Control.CreateControl(Boolean flgnore Visible)
    at System.Windows.Forms.Control.CreateControl()
    at System.Windows.Forms.Control.WmShowWindow(Message&m)
    at System.Windows.Forms.Control.WindProc(Message&m)
    at System.Windows.Forms.ScrollableControl.WindProc(Message& m)
    at System.Windows.Forms.Form.WmShowWindow(Message&m)
    at System.Windows.Forms.Form.WindProc(Message&m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(lntPtr hWind. lnt32msg. lntPtr wparam,lnt Ptr lntPtr lparam)
    **********Loaded Assemblies********

然后我尝试在Visual Studio 2005 C#中打开它,显示错误:

Unable to read the project file "CameraTestApp.csproj". C:\......:The imported project "C:\Microsoft.CSharp.targets" was not found. Confirm that the path in the <Import declaration > is correct, and that the file exists on disk.

我也厌倦了在记事本中打开项目并将其更改<Import Project=>"$(MSBuildToolsPath)""$(MSBuildBinPath)"尽管可以在进行更改后将其打开,但仍会出现一些错误,例如

"The imported project "C:\Microsoft.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct and that the file exists on disk"

这真令人沮丧。我不知道我应该继续尝试哪个版本的Visual Studio。以及这些错误的原因可能是什么。另外,我还没有深入研究代码,而且我是C#的新手。因此,我不确定这是Visual Studio的不同版本还是此新计算机设置的问题。这个应用程序的exe文件在旧计算机上可以正常运行,所以我认为这不是因为代码。

vmg

在您的项目文件中尝试以下操作:

<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章