简体   繁体   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#

I got this new Windows 7 64-bits PC today. 我今天得到了这款新的Windows 7 64位PC。 There is an application, which was written using visual studio 2005 C# on vista 64-bits, has to be transferred to this new PC. 有一个应用程序是使用Visual Studio 2005 C#在Vista 64位上编写的,必须转移到这台新PC上。 However, I tried to use visual studio 2010 c # express to run it, and then this error pops up: 但是,我尝试使用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********

And then I tried to open it in visual studio 2005 C#, an error shows up: 然后我尝试在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.

I also tired to open the project in Notepad and change the <Import Project=>"$(MSBuildToolsPath)" to "$(MSBuildBinPath)" . 我也厌倦了在记事本中打开项目并将<Import Project=>"$(MSBuildToolsPath)"更改为"$(MSBuildBinPath)" Although I can open it after the change is made, I get some errors like 尽管可以在进行更改后将其打开,但仍会出现一些错误,例如

"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"

This is frustrating. 这真令人沮丧。 I don't know which version of visual studio I should be keep trying. 我不知道我应该继续尝试哪个版本的Visual Studio。 And what might be the causes of these errors. 以及这些错误的原因可能是什么。 Plus, I haven't look deep into the code, and I am new in C#. 另外,我还没有深入研究代码,而且我是C#的新手。 Therefore, I'm not sure if it is the problem of different versions of visual studio, or this new computer setup. 因此,我不确定这是Visual Studio的不同版本还是此新计算机设置的问题。 The exe file of this app is running properly on the old computer, so I don't think it is because the code. 该应用程序的exe文件在旧计算机上可以正常运行,因此我认为这不是因为代码。

try this in your project file: 在您的项目文件中尝试一下:

<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.

相关问题 如何使用Visual Studio开发可在所有Windows OS XP,Vista,7、8上运行的C#应用​​程序 - How to develop c# application using visual studio which will run on all windows OS xp,vista,7,8 在Visual Studio 2010 C#中使用新的CultureInfo货币 - Using a new cultureinfo currency in Visual Studio 2010 C# 使用 Visual Studio 2010 将 VB 项目代码更改为 C# - Change VB project code to C# using Visual Studio 2010 使用C#Windows窗体在Visual Studio中创建新页面 - Creating new pages in Visual Studio using C# Windows Forms 在Visual Studio 2010 C#中发布代码 - Releasing a code in visual studio 2010 C# Visual Studio 2010 C#调试器不会在新的断点上停止 - Visual Studio 2010 C# Debugger Does not Stop on New Breakpoints 如何运行此 C# 代码。 使用 Visual Studio - How to run this C# code. using Visual Studio 在 Visual Studio 中编写的 C# 代码不会在 Visual Studio Code 中运行 - C# code written in Visual Studio won't run in Visual Studio Code 我已经使用Visual Studio Express C#为2010 Office(64位)编写了Excel代码,如何在2010 Office(32位)上运行它? - I have written excel code for 2010 Office (64 bit) with visual studio express c#, how to run it on 2010 office (32 bit)? 如何使用 Visual Studio 2022 构建用 C# 编写的应用程序 - How to build an application written in C#, using Visual Studio 2022
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM