Problem with a "phantom" (unexisting) server class misteriously created

M

MIGUEL?N.

Hi all!

Be patient because what I'm going to explain all of you it's more than
very strange.

I've developed a webservice project that contains two classes. One of
them is going to act as a SOAP header, and the other class is the main
class containing all the web methods. Besides, the project contains
two references pointing at two normal DLLs built also with VS .NET
2003. This references are needed because the web methods use them in
several ways.

The WebService must be accessed from a Winforms appplication over SSL.
Therefore, I've deployed the webservice on the server, have installed
server certificate and so on. No problems at all.

From my Winforms application, I add a Web Reference to the WebService
writting all the adress like this: https//xxx/WS/Service.asmx. The
reference (named "localhost") is added without any problems.

When I start programming and write: "localhost.", intellisense shows
me three classes instead of the two I've programmed! This third class
is a class that is assembled in one of the DLL's to which my web
service points. It's the class webmethods are using. But I've no
created any class! VS.NET has done it for me? Incredible!

Then I call a webmethod that must return me an IList (filled with
objects of the third's class type ) and instead of that, it returns me
an array of simple objects. The problem grows when I'm going to cast
this simple objects of the array to the class I use in my Winforms
application (same type of the third's appeared class). I got an
execution error telling me "Invalid cast operation".

The provisional solution is to cast this objects of the array to the
third class that has been generated when adding the web reference.
However if I then want to cast this objects (represented by a remote
reference of the third class) one by one to my local type of objects
(both of them should be of the same type), application also crashes
with an "Invalid cast operation". It seems like the objects of the two
classes (remote and local) are distinct.

I know my explanation sounds incredible and besides, I found it very
difficult to explain it with words. If you need more details, please
let me know.

Any help would be greatly appreciated. Thanks in advance.
 
D

Dan Rogers

Hi,

You seem to be describing the generated proxy when you reference the term
'localhost' in the sentence where you described intellisense. The
generated proxy will have the methods you expect, as well as new versions
of any types that are passed as parameters or returned from your methods.
This is the extra class you see.

Since this is the generated proxy, in the namespace localhost, you cannot
cast it to the same types as found in your project - the reason is that
they are in different namespaces. You can work around this by custom
coding the proxy (e.g. don't use the auto-generated one). Open the code
for the generated proxy, comment out the extra code that shadows the shape
of your original classes, and then add a "using" statement to the top of
the proxy code file and make it reference the namespace of your extra DLL.
This makes your proxy share your types with your service. At this point,
the cast will work.

Hope this helps,

Dan Rogers
Microsoft Corporation


--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top