My.Application.Info

6 posts, 0 answers
  1. Harald
    Harald avatar
    48 posts
    Member since:
    Oct 2013

    Posted 25 Dec 2014 Link to this post

    If I want to read the product name with vb.net my.application.info in my WPF Project, I get an error message.

    System.InvalidCastException wurde nicht behandelt.
      HResult=-2147467262
      Message=Das Objekt des Typs "TelerikWpfApp16.TelerikWpfApp16.Application" kann nicht in Typ "TelerikWpfApp16.Application" umgewandelt werden.
      Source=TelerikWpfApp16
      StackTrace:
           bei TelerikWpfApp16.My.MyWpfExtension.get_Application() in c:\users\hfrede\documents\visual studio 2013\Projects\TelerikWpfApp16\TelerikWpfApp16\My Project\MyExtensions\MyWpfExtension.vb:Zeile 20.
           bei TelerikWpfApp16.MainWindow.btnOK_Click(Object sender, RoutedEventArgs e) in c:\users\hfrede\documents\visual studio 2013\Projects\TelerikWpfApp16\TelerikWpfApp16\MainWindow.xaml.vb:Zeile 17.
           bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
           bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
           bei System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
    ...
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 Dec 2014 Link to this post

    Hi,

    The error message translated to English would be something like:
    The object of the "TelerikWpfApp16.TelerikWpfApp16.Application" can not be converted to type 'TelerikWpfApp16.Application ". Would you please check how have you defined your namespaces? What logic have you implemented on your MainWindow.btnOK_Click?

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Harald
    Harald avatar
    48 posts
    Member since:
    Oct 2013

    Posted 27 Dec 2014 in reply to Dimitrina Link to this post

    MainWindow.btnOK_Click-Code:

    MyConfigTable.ReadXml(My.Application.Info.DirectoryPath & "\" & "configuration.xml")

    Before I used in this project the Telerik controls, this call has worked.
  5. Harald
    Harald avatar
    48 posts
    Member since:
    Oct 2013

    Posted 27 Dec 2014 Link to this post

    I have created a simple test project. Here is the XAML:

    <Window x:Name="MyMainWindow" x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    Title="MainWindow" Height="350" Width="525">
    <Grid>

    </Grid>
    </Window>

    VB-Code:

    Class MainWindow

    Private Sub MyMainWindow_Loaded(sender As Object, e As RoutedEventArgs) Handles MyMainWindow.Loaded

    Me.MyMainWindow.Title = My.Application.Info.ProductName

    End Sub
    End Class

    ​Again, I get the same error message.
  6. Harald
    Harald avatar
    48 posts
    Member since:
    Oct 2013

    Posted 27 Dec 2014 Link to this post

    The same simple test project I created without Telerik controls. This will work.

    XAML:
    <Window x:Name="MyMainWindow" x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Grid>

    </Grid>
    </Window>

    VB:
    ​Class MainWindow

    Private Sub MyMainWindow_Loaded(sender As Object, e As RoutedEventArgs) Handles MyMainWindow.Loaded
    Me.MyMainWindow.Title = My.Application.Info.ProductName
    End Sub

    End Class
  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 29 Dec 2014 Link to this post

    Hello,

    May I ask you to try isolating the issue in a demo project illustrating your exact setup and attach it in a new support ticket ? You can also take a look at this blog post for a reference on how to isolate an issue. 

    That way I can check it locally and advise further.

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready