簡體   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