2017-02-15 154 views
0

我在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

在我所有的WPF窗口的.xaml.cs文件

'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 
+0

检查两个系统和您项目的目标设置上的.Net版本,它可能与您在服务器上的版本不同。如果它是一个小项目,您可以尝试删除解决方案文件,甚至重新创建项目并在其中添加现有内容。并检查你的libs是哪个系统目标,并且mb尝试明确地设置你的x86项目。 – Shakra

回答

0

我发现是什么原因导致我的问题:

检查.NET版本和其他设置我投降后,只是创造了VS2015在64位机器上的一个新的WPF项目,增加了新的WPF的窗口和类,只是粘贴的代码。我不得不添加一个视图引用,最后只有Microsoft.ReportViewer.WebForms.dll丢失。我必须从C:\\Windows\Microsoft.NET\assembly\GAC_MSIL\中提取它并手动将其添加到我的项目参考中。

因此,在查看旧项目(x86)时,我所要做的就是将Microsoft.ReportViewer.WebForms.dll添加到项目中并正确编译。但奇怪的是,我没有收到关于缺失参考文献的任何错误。

相关问题