【发布时间】:2017-07-03 21:12:51
【问题描述】:
我在 Windows 7 x86 机器上创建了一个 Visual Studio 2015 WPF 项目。平台目标是“任何 CPU”,但选中了“首选 32 位”复选框。代码编译,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?)
在我所有 WPF 窗口的 .xaml.cs 文件中。
当我复制 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:在旧机器上,我在项目中添加了一些 dll,难道这些都是针对 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 版本,它可能与服务器上的版本不同。如果它是一个小项目,您可以尝试删除解决方案文件,甚至重新创建项目并在其中添加现有的东西。并检查您的库是哪个系统目标,然后 mb 尝试为 x86 明确设置您的项目。
标签: c# wpf visual-studio visual-studio-2015 migration