我在Windows 7 x86机器上创建了Visual Studio 2015 WPF项目。平台目标是“任何CPU”,但选中“首选32位”复选框。代码编译和WPF应用程序工作。Visual Studio WPF项目迁移
然后,我在Windows Server 2012 R2 x64机器上安装了Visual Studio 2015,并将整个VS解决方案文件夹复制到新机器上。
现在看来VS2015并不认为该项目是WPF项目了。我得到这样的错误
The name 'InitializeComponent' does not exist in the current context
或
'AddService' does not contain a definition for 'sLAModelText' and no extension method 'sLAModelText' accepting a first argument of type 'AddService' could be found (are you missing a using directive or an assembly reference?)
。
当我复制VS解决方案时,没有命名空间或类名更改。我只需要删除并重新添加对Microsoft.Office.Core的引用。
此外,新机器没有连接到互联网。我不知道这是否会改变任何事情。
任何想法的人?
EDIT1:另外,我得到一个警告
Unknown build error, 'Cannot resolve dependency to assembly 'Microsoft.SharePoint.Client.Runtime, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.'
EDIT2:当旧的机器上,我增加了一些动态链接库的项目,会不会是这些明确为x86?但那么为什么VS2015不承认WPF项目?这些DLL文件:
Microsoft.Office.Client.Education.dll
Microsoft.ReportViewer.WinForms.dll
Microsoft.SharePointClientRuntime.dll
Microsoft.SqlServer.Types.dll
MigraDoc.DocumentObjectModel-WPF.dll
MigraDoc.Rendering-WPF.dll
MigraDoc.RtfRendering-WPF.dll
PdfSharp.Charting-WPF.dll
PdfShart-WPF.dll
检查两个系统和您项目的目标设置上的.Net版本,它可能与您在服务器上的版本不同。如果它是一个小项目,您可以尝试删除解决方案文件,甚至重新创建项目并在其中添加现有内容。并检查你的libs是哪个系统目标,并且mb尝试明确地设置你的x86项目。 – Shakra