2017-02-15 151 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添加到項目中並正確編譯。但奇怪的是,我沒有收到關於缺失參考文獻的任何錯誤。

相關問題