none
null reference exception :object reference not set to an instance of an object RRS feed

  • Question

  • hello all,

    i am trying to create an object for a window to do unit testing

    [test method]

    window_test()

    {

    window win=new window();//window is a xaml class (xaml.cs)

    }

    i got an exception like a object reference not set to an instance of an object ,please help me to resolve this issue.please help me to know the difference between normal class and xaml class

    Friday, May 17, 2019 10:31 AM

Answers

  • This is not remotely valid C# code. Please post your actual C# code that you're getting the error on (using the Insert Code Block tool please) along with the exact exception you're getting including the full call stack.

    Michael Taylor http://www.michaeltaylorp3.net

    • Marked as answer by TJANA Monday, May 20, 2019 7:01 AM
    Friday, May 17, 2019 1:58 PM
    Moderator

All replies

  • WPF that uses XAML can be discussed at the WPF forum.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wpf

    • Marked as answer by TJANA Monday, May 20, 2019 4:15 AM
    • Unmarked as answer by TJANA Monday, May 20, 2019 4:38 AM
    Friday, May 17, 2019 1:01 PM
  • Hello,

    Is there a window actually named window? If so I would change the name to a more informative name e.g. MainWindow.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, May 17, 2019 1:39 PM
    Moderator
  • This is not remotely valid C# code. Please post your actual C# code that you're getting the error on (using the Insert Code Block tool please) along with the exact exception you're getting including the full call stack.

    Michael Taylor http://www.michaeltaylorp3.net

    • Marked as answer by TJANA Monday, May 20, 2019 7:01 AM
    Friday, May 17, 2019 1:58 PM
    Moderator
  • Hi TJANA,

    Thank you for posting here.

    For your question, could you provide the complete code and exception?

    Besides, If your question is related to xaml, you could post in the WPF forum. If your question is more related unit test, you could post in the Unit test forum.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 20, 2019 3:02 AM
    Moderator
  • Thank you  for your help.there window is a mainwindow that is a UI class.

    Monday, May 20, 2019 7:04 AM
  • Again, the code you posted cannot compile. [test method] is not valid C#. window_test() indicates a constructor call which means it is contained in the same named class.

    Please post ALL the code that you're trying to run. Also please post the exact exception you're getting including the type, message and callstack. This information is available through the test window. It has most of the answers to your problem but since we cannot see it we cannot help you.


    Michael Taylor http://www.michaeltaylorp3.net

    Monday, May 20, 2019 2:09 PM
    Moderator