這發生在我的基於WPF的解決方案中的幾個新舊項目中。我剛剛添加了一個名爲Dashboard
的窗口,並在生成的'Dashboard.xaml.vb file, I entered the following code. Note it normally pastes
InitializeComponent in for you when you create
Sub New`中,但現在沒有。所以,我有:WPF解決方案非常奇怪
Public Class DashBoard
Public Sub New()
InitializeComponent()
End Sub
End Class
答編譯器會抱怨說:
錯誤15 '的InitializeComponent' 未聲明。由於其保護級別,可能無法訪問 。
就好像IDE不知道這是Window背後的代碼。某種局部類或鏈接的丟失,但在vbproj文件,我們仍然發現鏈接:
<Compile Include="Bridge.xaml.vb">
<DependentUpon>Bridge.xaml</DependentUpon>
</Compile>
我對所有項目進行自動記錄錯誤使用PostSharp,但在此之前它從未給我找麻煩。這是非常好的表現。
新增:
`Dashboard.xaml很像:
<Window x:Class="DashBoard"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="DashBoard" Height="300" Width="300">
<Grid>
</Grid>
</Window>
和`Dashboard.xaml.vb「看起來像這樣:
Public Class DashBoard
End Class
那不行,我試過了。 VS應該在VB.NET項目中爲黑盒魔術做所有這些事情。如果Ii不能使用C#,請告訴客戶填充它。 – ProfK 2014-10-04 16:47:33
檢查'.xaml'和'.xaml.vb'文件是否通過關閉VS並在某些文本編輯器中打開'.vbproj'文件來相互連接,然後搜索'Dashboard.xaml.vb':它應該包含一個類似於' Dashboard.xaml DependentUpon> '的條目,因爲這告訴VS這兩個文件「屬於一起」 –
andreask
2014-10-04 17:02:55
它們是這樣連接的。 – ProfK 2014-10-04 18:20:17