Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Where is ServiceHost<T>?

14 views
Skip to first unread message

sa.c...@gmail.com

unread,
Sep 15, 2005, 6:42:24 AM9/15/05
to
It seems,september CTP is missing ServiceHost<T>?What is replacement
for this?

Thanks.

Ondrej Hrebicek [MSFT]

unread,
Sep 16, 2005, 9:10:49 PM9/16/05
to
Old ServiceHost<T> is now ServiceHost. Old ServiceHost is now
ServiceHostBase.

"Bijan" <Bi...@discussions.microsoft.com> wrote in message
news:6D2CBE5E-1B93-4914...@microsoft.com...
> The generic version of ServiceHost is gone! Try the non-generic one.

sa.c...@gmail.com

unread,
Sep 17, 2005, 7:14:19 AM9/17/05
to
So,instead of using(ServiceHost<T> h ...){} I must write something like
using(ServiceHost h..){
h.AddEndpoint(typeof(T));
} ?
Generic version for instantion from config looks nicer IMHO.

Thanks.

sa.c...@gmail.com

unread,
Sep 17, 2005, 7:19:25 AM9/17/05
to
It seems Service host dosen't have empty constructor anymore,so I need
a Type and baseAddresses but how about base adress from config?
By the way,most of examples in september CTP SDK still refer to generic
type even in docs.

Regards.

Ondrej Hrebicek [MSFT]

unread,
Sep 17, 2005, 1:26:49 PM9/17/05
to
In the past, you would write:
using (ServiceHost<MyService> host = new ServiceHost<MyService>(new
Uri("scheme://hostname/base")))
{ ... }

You would now write:
using (ServiceHost host = new ServiceHost(typeof(MyService), new
Uri("scheme://hostname/base")))
{ ... }

Endpoints are still added in config. You've always needed a type and base
address at ServiceHost construction time - base addresses are not
specify-able in config (since a hosting environment, usually WebHost,
determines them), and the type is specified in config only so the product
can make the match.

I'll make sure the samples team is aware of the inconsistency,
Ondrej

<sa.c...@gmail.com> wrote in message
news:1126955965....@z14g2000cwz.googlegroups.com...

Steve Eichert

unread,
Sep 17, 2005, 9:38:24 PM9/17/05
to
What was the reason for getting rid of the generic version? It seems strange
to go back to pre .NET 2.0 type API's. Constructors with typeof() seem so
yesterday ;-)

I also don't like that you have to specify a Uri when you instantiate the
service host. I think being able to speficy it in the config file and have
the ServiceHost pick that up is much more flexible.

Michael Latta

unread,
Sep 17, 2005, 11:42:02 PM9/17/05
to
At PDC the person I asked indicated that many of the top level public APIs
were being changed to not use Generics because the typical IT programmer
found them confusing. So much for progress. I suggested that they try to
have both versions, but that apparently would also be confusing because it
requires a choice be made between the 2 versions. This also relates to the
petition going around to limit changes to C# because it is becoming too
complicated to learn the language features.

What this suggests to me is that the drive to make strong typing more and
more flexible is showing a fundamental issue. Strong typing creates
coupling that has nothing to do with a properly running application, or with
what methods get executed (which are determined at run time in any event).
Strong typing has 2 advantages. It is still faster, and it provides
intelesense. Compiler error checking does not replace testing, but is
replaced by testing. Intelesense can be supported with type inference, and
hinting. It will be interesting to see if C# goes the way of C++, and it
may take Visual Basic with it as all those features are now being added to
both languages.

Michael


"Steve Eichert" <eich...@hotmail.com> wrote in message
news:7742ffa5fd8a8...@news.microsoft.com...

Steve Eichert

unread,
Sep 18, 2005, 12:08:31 AM9/18/05
to

I find it confusing that they would do such a thing. Perhaps we should take
Generics out of the runtime as well? And maybe we should get rid of those
pesky && and || operators. In fact we should probably just stop all work
on things that would advance the platform. Hrm, but wouldn't that include
Indigo? Do "typical IT programmers" find service orientation confusing?
Let's just scrap it all.

Martin Gudgin

unread,
Sep 18, 2005, 3:23:39 AM9/18/05
to
You don't have to specify a base URI, you can just say;

ServiceHost sh = new ServiceHost(typeof(MyImplementationType));

And you can specify type, base URI et.al. in config if you want to.

Gudge

"Steve Eichert" <eich...@hotmail.com> wrote in message
news:7742ffa5fd8a8...@news.microsoft.com...

sa.c...@gmail.com

unread,
Sep 18, 2005, 6:39:16 AM9/18/05
to
Strange,but Reflector shows only "public ServiceHost(Type serviceType,
params Uri[] baseAddresses);" constructor,but you're right-that's
work,thanks a lot!
<Ondrej Hrebicek [MSFT]>

- base addresses are not
specify-able in config (since a hosting environment, usually WebHost,
determines them), and the type is specified in config only so the
product
can make the match.
</Ondrej Hrebicek [MSFT]>
but how about self-hosting:
<service serviceType="load.GenericMessageEndpoint" >
<endpoint
address = "net.pipe://localhost/quickstarts/service"
bindingSectionName = "netProfileNamedPipeBinding"
bindingConfiguration="aaa"
contractType = "load.IGenericMessageEndpoint" />
</service>

it seems to work just fine,but thanks anyway:-)

sa.c...@gmail.com

unread,
Sep 18, 2005, 6:52:43 AM9/18/05
to
Entirely agree with you,Steve.
By the way Nullable<T> based on generics and strongly suggested to wide
use and generics itself promote as one of main features in upcoming
release,now we found that all that is bad practice-framework dosen't
use fetuares it contains.I have bad feeling about this...
<quote>

were being changed to not use Generics because the typical IT
programmer
found them confusing.
</quote>
What else "typical" programmer found confusing?Why presentation of all
great c# 3 features on PDC?
Shame on microsoft,how about innovations?Let us get dumb and average...

Roman Kiss [MVP]

unread,
Sep 18, 2005, 11:14:14 AM9/18/05
to
> <service serviceType="load.GenericMessageEndpoint" >
> <endpoint
> address = "net.pipe://localhost/quickstarts/service"
> bindingSectionName = "netProfileNamedPipeBinding"
> bindingConfiguration="aaa"
> contractType = "load.IGenericMessageEndpoint" />
> </service>

The above configuration has been slightly changed (keeping in mind ABC)

<service type="load.GenericMessageEndpoint" >


<endpoint
address = "net.pipe://localhost/quickstarts/service"

binding = "netNamedPipeBinding"
bindingConfiguration="aaa"
contract = "load.IGenericMessageEndpoint" />
</service>


Roman


<sa.c...@gmail.com> wrote in message
news:1127039956.0...@g44g2000cwa.googlegroups.com...

Ondrej Hrebicek [MSFT]

unread,
Sep 18, 2005, 2:58:37 PM9/18/05
to
Ah, forgot about that. You can't specify base addresses in config but, as
you found out, you can just specify fully qualified addresses at the
endpoint level. Note that that will work in WebHost, too, as long as the
base address matches the one WebHost assigned to your service. This practice
is generally discouraged as there is rarely a good reason for it, other than
possibly the edge case where your app is hosted both ways and you want to
share the configuration file (but even in that case, a safer bet is to just
use relative addresses in config and specify the base address at ServiceHost
construction time).

<sa.c...@gmail.com> wrote in message
news:1127039956.0...@g44g2000cwa.googlegroups.com...

Ondrej Hrebicek [MSFT]

unread,
Sep 19, 2005, 2:29:40 AM9/19/05
to
We did not remove the generic version of ServiceHost because we thought it
was confusing to developers. Our next primary class, ChannelFactory<T>, is
generic and will remain so. We did it simply because it wasn't the right
thing to do. One of the primary reasons was that ServiceDescription was only
available on the ServiceHost<T> class. Certainly a very useful property, it
was often very difficult to obtain because one needed to know what T was so
they could cast to the appropriate type to get to it. In fact, it was
possible T would be unknown entirely and the caller (for example a generic
hosting environment) would have to resort to reflection. All in all, there
simply was no real benefit to using a generic type there.

Ondrej

<sa.c...@gmail.com> wrote in message
news:1127040763....@g44g2000cwa.googlegroups.com...

sa.c...@gmail.com

unread,
Sep 20, 2005, 8:26:30 AM9/20/05
to
Thanks for clarify things out,certainly generics is not very "generic"
approach in this case;-)

0 new messages