【问题标题】:Visual Studio WPF project migrationVisual Studio WPF 项目迁移
【发布时间】: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


【解决方案1】:

我找到了导致我的问题的原因:

在检查了 .net 版本和其他设置后,我放弃了,刚刚在 x64 机器上的 VS2015 中创建了一个新的 WPF 项目,添加了新的 WPF 窗口和类,然后粘贴了代码。我不得不添加一个视图引用,最后,只有Microsoft.ReportViewer.WebForms.dll 丢失了。我不得不从C:\\Windows\Microsoft.NET\assembly\GAC_MSIL\ 中提取它并手动将其添加到我的项目引用中。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-22
    • 2012-09-16
    • 2017-02-06
    • 1970-01-01
    • 1970-01-01
    • 2011-12-29
    • 1970-01-01
    • 2023-03-16
    相关资源
    最近更新 更多