我在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
答案 0 :(得分:0)
我发现了导致我问题的原因:
在检查.net版本和其他设置后,我放弃了,只是在x64机器上的VS2015中创建了一个新的WPF项目,添加了新的WPF窗口和类,只是粘贴了代码。我必须添加一个视图引用,最后只缺少Microsoft.ReportViewer.WebForms.dll
。我必须从C:\\Windows\Microsoft.NET\assembly\GAC_MSIL\
中提取它并手动将其添加到我的项目的引用中。
因此,在查看旧项目(x86)时,我所要做的就是将Microsoft.ReportViewer.WebForms.dll
添加到项目中并正确编译。但奇怪的是,我没有收到遗失参考文献的任何错误。