Creating GUI - Null Valued Expression?

This topic contains 7 replies, has 4 voices, and was last updated by Profile photo of Jason Tira Jason Tira 2 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #40696
    Profile photo of Brent Balzer
    Brent Balzer
    Participant

    I am attempting to make a GUI that our Help Desk can utilize when deploying newly imaged machines. I apologize if this is a stupid question but I'm stumped.

    I am using ISE Steroids/Visual Studio to create it and am fairly confident I know what the issue is but I'm not entirely sure how to resolve the problem.

    When I run it on my computer it works fine but when I go to run the script or converted EXE on another machine I receive an error..

    You cannot call a method on a null-valued expression.
    At C:\Users\bb16480\Desktop\UItest.ps1:73 char:1
    + $SEP.add_Click(
    + ~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
    

    I couldn't get the code to load the $XAML in here so I put it in pastebin at: http://pastebin.com/MT1HvKxp

    #40706
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Well, it's thinking that $SEP doesn't actually contain anything. I'm not seeing that in your code, though. It seems as if you expect $SEP to be a form object...?

    BTW, you can also use Gists here. If you paste the Gist URL into the forums, it'll retrieve and display your code all pretty-like.

    #40708
    Profile photo of Brent Balzer
    Brent Balzer
    Participant

    Sorry, I believe I was testing something else but that didn't work and I put in the incorrect error. 🙁

    It's not $Sep it's $Windows.SEP

    You cannot call a method on a null-valued expression.
    At C:\Users\bb16480\Desktop\UItest.ps1:73 char:22
    + $window.SEP.add_Click < <<< (
        + CategoryInfo          : InvalidOperation: (add_Click:String) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
    

    This does run on my Win10 machine with ISE-Steroids but when I try to run this script on our normal Win7 client machines, this is when the error comes up. The GUI does popup but I still receive the error code.

    Hopefully that makes sense. I'm trying hard to wrap my head around all this. Also thanks for the tremendous sessions @MMS this year, it was fantastic.

    #40710
    Profile photo of Dan Potter
    Dan Potter
    Participant

    I don't see the rest of the code that creates the form at that link.

    #40712
    Profile photo of Brent Balzer
    Brent Balzer
    Participant

    Hopefully this helps for viewing?

    #40714
    Profile photo of Dan Potter
    Dan Potter
    Participant

    The form works for me on win7.

    $window.SEP.add_Click(
    {
    [System.Object]$sender = $args[0]
    [System.Windows.RoutedEventArgs]$e = $args[1]

    write-host 'sep clicked'

    }
    )

    #40722
    Profile photo of Brent Balzer
    Brent Balzer
    Participant

    Oy.... well it turns out it was something with the VM I was testing this on that caused an issue.

    Appreciate you checking it out and sorry about that. I was kind of banging my head on the wall the past hour or so in between some other work and it turns out it was fine after all.

    Uffta....

    #48216
    Profile photo of Jason Tira
    Jason Tira
    Participant

    Did you have any luck with figuring this out?
    I am seeing the same issue on a vista machine. I believe its due to something not being up to date, but Im not sure what.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.