Instance Error in xaml - Community Credit Forums
in

    Community Credit Forums

Instance Error in xaml

Last post Tue, Mar 31 2009 6:03 AM by amodkchandra. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • Fri, Dec 12 2008 4:34 AM

    Instance Error in xaml

    Whenever I try to run my WPF application (window1.xaml) I get the following error :

    "Cannot create instance of 'Window1' defined in assembly 'C1WPFGrid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Window1.xaml' Line 1 Position 9. "

    Why is this occuring ?  

    Also when I use 'namespace' in code behind file (window1.xaml.vb) the Initialize Component gives an error : 

     "Name 'InitializeComponent' is not declared" I have also given  the code below:

    Namespace C1DataGrid1

    Partial Public Class Window1

    Inherits System.Windows.WindowPublic Sub New()

    InitializeComponent()

    Dim ProdTBL As New DataTable

    Dim OleDBConnection As OleDb.OleDbConnection

    Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\ComponentOneStudio.NET 3.0\Common\Nwind.mdb"

    OleDBConnection = New OleDb.OleDbConnection(connString)

    Dim query As String

    query = "SELECT ProductID, ProductName,UnitPrice FROM Products"

    Using conn As New OleDb.OleDbConnectionDim da As New OleDb.OleDbDataAdapter(query, conn)

    da.Fill(ProdTBL)

    Dim CIGrid As C1.WPF.C1DataGrid.C1DataGrid = TryCast(Me.FindName("C1DataGrid1"), C1.WPF.C1DataGrid.C1DataGrid)

    CIGrid.ItemsSource = ProdTBL

    End Using

    DataContext = ProdTBL

    End Sub

    Private _productsDataSet As ProductsDS = Nothing

    Public ReadOnly Property ProductsDataSet() As ProductsDS

    Get

    If _productsDataSet Is Nothing Then

    _productsDataSet = New ProductsDSDim prodTA As New ProductsTableAdapter

    prodTA.Fill(_productsDataSet.Products)

    End If

    Return _productsDataSet

    End Get

    End Property

    End Class

    End Namespace

     

    PLEASE HELP !!! 

     

    Regards ......... Happyarimaan

    Be who you are and say what you feel, because those who mind don't matter
    and those who matter don't mind.
  • Tue, Mar 31 2009 6:03 AM In reply to

    Re: Instance Error in xaml

    This exception is thrown whenever something goes wrong while the XAML code is parsed. However, this exception is not very helpful. So what exactly went wrong? Well, it's easy to find out: In the code-behind, the XAML code is parsed in the method InitializeComponent which is automatically generated. This method is called in the Window object's constructor. So to have more details about the exception, put the call to InitializeComponent in a try/catch block. This way, you have access to the useless XamlParseException, but also to its InnerExceptions and to the StackTrace.

    Partial Public Class Window1 Inherits System.Windows.Window

    Public Sub New()

    Try

    InitializeComponent()

    Catch ex As Exception

    End Try

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems