[英]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.