VS 2017 [RESOLVED] WPF Application_Startup is not a member of Application | Command line launch-VBForums
Results 1 to 2 of 2

Thread: [RESOLVED] WPF Application_Startup is not a member of Application | Command line launch

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2016
    Posts
    68

    Resolved [RESOLVED] WPF Application_Startup is not a member of Application | Command line launch

    Good Afternoon,

    I know I am just doing/forgetting something super dumb! I want my WPF application to launch via command line and process arguments. I have tried to fidget around with it but cannot get this one error to go away. The error is "Application_Startup is not a member of Application". I would appreciate if someone could just nudge me in the right direction. Thank you.

    I set the startup event in my application.xaml to the name of my sub
    Code:
    <Application x:Class="ESTClient.Application" 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" Startup="Application_Startup">
        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/System.Windows.xaml" />
                    <ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.xaml" />
                    <ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />
                    <ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Docking.xaml" />
                    <ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Documents.xaml" />
                    <ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.FixedDocumentViewers.xaml" />
                    <ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.FixedDocumentViewersUI.xaml" />
                    <ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.Input.xaml" />
                    <ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.ImageEditor.xaml" />
                    <ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.RibbonView.xaml" />
                    <ResourceDictionary Source="/Telerik.Windows.Themes.VisualStudio2013;component/Themes/Telerik.Windows.Controls.RichTextBoxUI.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </Application.Resources>
    </Application>
    Application.vb looks like this:
    Class Application
    Inherits System.Windows.Application


    ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException
    ' can be handled in this file.
    Friend doc As String
    Friend docType As String

    Private Sub Application_Startup(sender As Object, e As StartupEventArgs)
    Dim args() As String = Environment.GetCommandLineArgs()
    ' If no command line arguments were provided, don't process them
    If args.Length = 0 Then
    Return
    End If


    ' Get command line arguments
    For Each argument As String In args


    argument = argument.ToLower


    'Its a Tiff
    If argument.EndsWith("tif") Then
    docType = "img"
    doc = argument
    ElseIf argument.EndsWith("tiff") Then
    docType = "img"
    doc = argument
    'Its a PDF
    ElseIf argument.EndsWith("pdf") Then
    docType = "pdf"
    doc = argument
    'Its a JPG
    ElseIf argument.EndsWith("jpg") Then
    docType = "img"
    doc = argument
    'Its HTML
    ElseIf argument.EndsWith("html") Then
    docType = "html"
    doc = argument
    ElseIf argument.EndsWith("htm") Then
    docType = "html"
    doc = argument
    'Its PNG
    ElseIf argument.EndsWith("png") Then
    docType = "img"
    doc = argument
    'Its Text
    ElseIf argument.EndsWith("txt") Then
    docType = "html"
    doc = argument
    'Its CSV
    ElseIf argument.EndsWith("csv") Then
    docType = "html"
    doc = argument
    'Its XML
    ElseIf argument.EndsWith("xml") Then
    docType = "html"
    doc = argument
    'We want the folder browse
    'ElseIf argument.StartsWith("/e") Then
    ' folderBool = True
    ' file = argument.Substring(2)
    'ElseIf argument.StartsWith("/B") Then
    ' gmapsBool = True
    ' addr = argument.Substring(2)
    'ElseIf argument.StartsWith("/b") Then
    ' gmapsBool = True
    ' addr = argument.Substring(2)
    End If
    Next argument
    End Sub
    End Class

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Mar 2016
    Posts
    68

    Re: WPF Application_Startup is not a member of Application | Command line launch

    Nevermind, I thought you had to parse command line arguments to launch your application in application.xaml file.

    Apparenly, I can just do it right in the sub new of my main window so I will just do that. Works great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width