【问题标题】:TypeLoadException on navigating to a page from usercontrol从用户控件导航到页面时出现 TypeLoadException
【发布时间】:2013-12-21 20:37:19
【问题描述】:

我的用户控件中有这段代码:

Private Sub tap(sender As Object, e As TappedRoutedEventArgs) Handles Me.Tapped
     Try
        CType(Window.Current.Content, Frame).Navigate(GetType(calendar_day))
        'calendar_day is a page in project'
    Catch ex As Exception
        Debug.WriteLine(ex.HelpLink)
        Debug.WriteLine(ex.HResult)
        Debug.WriteLine(ex.InnerException)
        Debug.WriteLine(ex.Message)
        Debug.WriteLine(ex.Source)
        Debug.WriteLine(ex.StackTrace)
    End Try
End Sub

输出:

A first chance exception of type 'System.TypeLoadException' occurred in Organize.exe

-2146233054

Could not find Windows Runtime type 'Windows.Foundation'.
mscorlib    
at System.StubHelpers.WinRTTypeNameConverter.GetTypeFromWinRTTypeName(String typeName, Boolean& isPrimitive)
at System.StubHelpers.SystemTypeMarshaler.ConvertToManaged(TypeNameNative* pNativeType, Type& managedType)
at Windows.UI.Xaml.Controls.Frame.Navigate(Type sourcePageType)
at Organize.day_btn.clicked(Object sender, TappedRoutedEventArgs e)

我尝试过清理、重建、构建 x64 和 x86,但没有任何帮助。

【问题讨论】:

    标签: vb.net xaml user-controls windows-8.1


    【解决方案1】:

    我首先将 calendar_day 创建为 BlankPage1,然后重命名文件和类。但是在 calendar_day.xaml 我离开了x:Class="Organize.BlankPage1"

    【讨论】:

    • 感谢您的提示。我遇到了类似的错误,原因是 Page 类应该位于 Views 命名空间中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多