Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Windows 7 Forum Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

Converting proxy generated types to original types

Update your Vista Drivers Update Your Drivers Now!!
 
 
Thread Tools Display Modes
Old 01-03-2007   #1 (permalink)
Daniel
Guest


 

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
Guest


 

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
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting array elements between types Kryten PowerShell 6 03-01-2008 12:25 PM
File types Ernie Lane Vista General 4 10-17-2007 10:25 PM
File Types dev Vista General 4 07-16-2006 05:45 PM
File Types =?Utf-8?B?VGVhbWhyYw==?= Vista General 0 07-07-2006 01:41 PM


Vistax64.com 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 2005-2008

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