weird changes in method signature

B

Bamse

Hi,

I've noticed that if in a webservice method, I use an enumeration or a
struct of my own, in the project that references that webservice, the
method's signature is changed, e.g:

proj1:
public struct S1
{
public string Member1;
public int Member2;
}

ws_proj
{
DoSomething(S1 myStruct)
{
...
}
}

proj3
{
using proj1;
main()
{
S1 myStruct = new S1();
ws_proj.DoSomething(myStruct); // this line does not
compile: cannot convert proj1.S1 to localhost.S1
}
}

why is this happening and how can be avoided/solved without manually
rewriting reference.cs of the WS?
i use VS .NET 2002.

Thank you,
Daniel
 
N

Nicholas Paldino [.NET/C# MVP]

Bamse,

The types are not compatable in the CLR space. Basically, when you set
a reference to the web method, a new type is being created for you that
represents the structure that is being passed to the web method. This type
is different from the type in proj1 (even though the members are the same).

You will have to copy the values from the type in proj1 to the other
that is defined by the web method itself in the WSDL.

Hope this helps.
 
Top