繁体   English   中英

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

[英]Code written using visual studio 2005 C# on vista does not run on new Windows 7 PC using visual studio 2010 C#

我今天得到了这款新的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文件在旧计算机上可以正常运行,因此我认为这不是因为代码。

在您的项目文件中尝试一下:

<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')" />

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM