locked
Windows Runtime component returns null string

    Question

  • Hello,

    This question should be very simple but I couldn't find any clue.

    I have a class A within a Windows Runtime component (using C#), which has a property b returning a string.

    When I used A.b in JavaScript, always got "Invalid point" and "Value cannot be null" in the case when b is null.

    It's like this:

    // C#

    sealed public class A

    {

        public string b { get { return null; }}

    }

    // JavaScript

    var objA = ....; // initialize A

    function test()

    {

       var value_b = objA.b;   // throws nullpointer exception

    }

    Thanks a lot!

    Wednesday, March 12, 2014 12:05 AM

Answers

  • An ArgumentNullException exception is thrown when a method is invoked and at least one of the passed arguments is null but should never be null.

    And I don't think WinRT component accept null value even string is capable with null. But you could use String.Empty instead.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.



    Wednesday, March 12, 2014 3:27 AM
    Moderator

All replies

  • An ArgumentNullException exception is thrown when a method is invoked and at least one of the passed arguments is null but should never be null.

    And I don't think WinRT component accept null value even string is capable with null. But you could use String.Empty instead.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.



    Wednesday, March 12, 2014 3:27 AM
    Moderator
  • Thanks.
    Wednesday, March 12, 2014 6:35 AM