Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - Converting proxy generated types to original types

 
 
Old 01-03-2007   #1 (permalink)
Daniel


 
 

Converting proxy generated types to original types

I have a WCF Service called "MyService". It references a DLL that
defines a type called "SomeLib.MyType". "SomeLib.MyService" exposes
the following contract method:

[OperationContract]
SomeLib.MyType MyMethod();

On the client side, a proxy is being generated for MyType, let's call
it "MyProxy.MyType". Simple stuff.

Now, say I have a library that performs calculations on SomeLib.MyType.
It has a simple signature:

namespace MyLibrary
{
public class MyCalculator
{
public int Calculate(SomeLib.MyType x) { do something special }
}
}

The question is, how can I utilize "MyLibrary" from the client? I
can't pass "MyProxy.MyType" to "Calculate", because "MyType" on the
client it is generated as part of the proxy (via svcutil.exe).
Casting from MyProxy.MyType to SomeLib.MyType doesn't work (and perhaps
is dangerous).

Is there any other way of doing it, without writing a converter from
"MyProxy.MyType" to "SomeLib.MyType"?

Thanks in advance.


My System SpecsSystem Spec
Old 01-06-2007   #2 (permalink)
Joerg Jooss


 
 

Re: Converting proxy generated types to original types

Thus wrote Daniel,

> I have a WCF Service called "MyService". It references a DLL that
> defines a type called "SomeLib.MyType". "SomeLib.MyService" exposes
> the following contract method:
>
> [OperationContract]
> SomeLib.MyType MyMethod();
> On the client side, a proxy is being generated for MyType, let's call
> it "MyProxy.MyType". Simple stuff.
>
> Now, say I have a library that performs calculations on
> SomeLib.MyType.
> It has a simple signature:
> namespace MyLibrary
> {
> public class MyCalculator
> {
> public int Calculate(SomeLib.MyType x) { do something special
> }
> }
> }
> The question is, how can I utilize "MyLibrary" from the client? I
> can't pass "MyProxy.MyType" to "Calculate", because "MyType" on the
> client it is generated as part of the proxy (via svcutil.exe).
> Casting from MyProxy.MyType to SomeLib.MyType doesn't work (and
> perhaps
> is dangerous).
> Is there any other way of doing it, without writing a converter from
> "MyProxy.MyType" to "SomeLib.MyType"?


In that case, you're much better off sharing these types between client and
server -- in your scenario these are tightly coupled anyway.

Put the shared types in a separate assembly, deploy it on both client and
server, and use ChannelFactory<T> instead of svcutil-generated proxies in
your client code.

Cheers,
--
Joerg Jooss
news-reply@joergjooss.de


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Converting array elements between types PowerShell
Simple Types PowerShell
File Types Vista General
File Types Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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