• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 576
  • Last Modified:

returning a struct from a webservice

   struct MyStruct
    {
        public int x;
        public int y;
    };


 [WebMethod]
    public MyStruct getStruct()
    {

        MyStruct ms;
        ms.x = 10;
        ms.y = 20;
        return ms;

    }

Error      1      Inconsistent accessibility: return type 'Service.MyStruct' is less accessible than method 'Service.getStruct()'      d:\WebSite3\App_Code\Service.cs      78      21      d:\WebSite3\

This is the error I am getting

0
prgeorge3383
Asked:
prgeorge3383
  • 2
1 Solution
 
GENTPCommented:
have you tried making your struct into a class?
0
 
prgeorge3383Author Commented:
yes I did

<GenericObjectDataSource DisplayName="Order" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
   <TypeInfo>WindowsApplication1.localhost.Order, Web References.localhost.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>

Warning      1      The 'urn:schemas-microsoft-com:xml-msdatasource:GenericObjectDataSource' element is not declared.      C:\Documents and Settings\xxxxT\My Documents\Visual Studio 2005\Projects\WindowsApplication2\WindowsApplication2\Web References\localhost\Order.datasource      8      2      WindowsApplication2


This is the error I am getting with  a class
0
 
GENTPCommented:
did you update your web reference in your windows application? Just a thought.
0
 
mrichmonCommented:
Try adding the word public to the struct definition

public struct MyStruct
    {
        public int x;
        public int y;
    }
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now