Professional Web Applications Themes

C++ Reflection Problems - ASP.NET Web Services

Hi I have quite a strange problem that I can't seem to overcome on my own. I have a managed C++ web service which has one webmethod. This method returns an array of a class with 1 property in it. This array is created by another class which has IEnumerable and IEnumerator as its base class so that I can DataBind this type in the consuming application. The web service compiles fine but when you run it, it returns the following errors in the stack trace [NullReferenceException: Object reference not set to an instance of an object. [InvalidOperationException: There was ...

  1. #1

    Default C++ Reflection Problems

    Hi

    I have quite a strange problem that I can't seem to overcome on my own. I have a managed C++ web service which has one webmethod. This method returns an array of a class with 1 property in it. This array is created by another class which has IEnumerable and IEnumerator as its base class so that I can DataBind this type in the consuming application. The web service compiles fine but when you run it, it returns the following errors in the stack trace

    [NullReferenceException: Object reference not set to an instance of an object.

    [InvalidOperationException: There was an error reflecting 'QuickSortResult'.

    [InvalidOperationException: Method CService.QuickSort can not be reflected.

    [InvalidOperationException: Unable to handle request.

    [InvalidOperationException: Failed to handle request.

    I have created 2 different projects, a console application and a class library - both of those would compile the same code (mines the system::web stuff) just fine - the console app would run nicely and the class library was able to be referenced inside of another application and invoked. So suffice to say, I'm stuck! Here is the pertinent code below

    Number.h simply implement a class with a single property with get & set implemente

    -----------------------------------------------------------------
    //numbers.
    namespace numbersnamespac

    __gc public class numbers : public IEnumerable, public IEnumerato

    private
    static int position = -1;

    public:
    number *enumerator[];

    numbers(

    enumerator = new number * [NUM_ITEMS]

    ------------------------------------------------------------------------
    //Main.h
    __gc public class CServic
    {
    public:
    [WebMethod
    numbers* QuickSort();
    ------------------------------------------------------------------------
    //Main.cp
    numbers* CService::QuickSort(
    {
    //non important code is left ou

    numbers *sdata = new numbers()

    for (i = 0; i < NUM_ITEMS; i++
    sdata->enumerator[i] = new number(__numbers[i]);

    return sdata


    Any help/suggections are much appreciated, my email address is listed as well in case you would like to contact me that way

    Thanks in advance
    -Ra

    Ray Deese Guest

  2. #2

    Default RE: C++ Reflection Problems

    Hi Ray,

    From your code, I haven't found the definition for "__numbers[i]". Is it
    possible that this array or one of its items is null value at runtime and
    cause the problem?

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    [MSFT] Guest

  3. #3

    Default RE: C++ Reflection Problems

    Hi Ray,

    Have you checked if every item in the arry "__numbers" have actual value?
    This may be the cause of error "Object reference not set to an instance of
    an object.". Additionally, the error also may be related to Serializtion
    process of the web service. You may test follow code with sdata to if it
    will generate errors:

    XmlSerializer* serializer = new XmlSerializer(__typeof(numbers));

    TextWriter* writer = new StreamWriter(filename);

    serializer->Serialize(writer, sdata);
    writer->Close();

    This can help find if it can pass the Serializer of web service.

    Luke
    Microsoft Online Support

    Get Secure! [url]www.microsoft.com/security[/url]
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    [MSFT] Guest

Similar Threads

  1. Reflection map?
    By Pelleyoo in forum Macromedia Director 3D
    Replies: 6
    Last Post: April 16th, 05:09 PM
  2. Managed C++ Web Service - strange reflection problems
    By Ray Deese in forum ASP.NET Web Services
    Replies: 0
    Last Post: May 6th, 06:16 PM
  3. Problems with reflection
    By Holger Mescheder in forum Macromedia Director 3D
    Replies: 2
    Last Post: November 19th, 11:49 AM
  4. Self Reflection
    By Beth Haney in forum Adobe Photoshop Elements
    Replies: 3
    Last Post: August 1st, 02:41 PM
  5. Reflection on COM object.
    By Lars Nielsen in forum ASP.NET General
    Replies: 6
    Last Post: July 18th, 10:13 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139