What is the recommended way of hosting In NServiceBus 6, self hosting or NServiceBus.Host.exe? - nservicebus

It seems NServiceBus is moving from configuration to Code. What are the additional benefits of hosting using NServiceBus.Host.exe vs hosting an endpoint yourself?

Not sure what configuration via code has to do with hosting?
The NServiceBus Host offered features to make it easier to host your endpoints. Since then we have made a lot of this stuff easier or the features have been added to specific packages. So at the moment, it's as easy to host it yourself. And you'd have more control over setup, etc. For example the host has its own configuration and the endpoint itself as well. Some users have issues with assembly mappings that need to be in both places, etc.
So if you want to know how you can host yourself, there's documentation on that:
General hosting
Self hosting sample
Windows Service Hosting
Web Application Hosting
Service Fabric Hosting
Shared Hosting in Azure
and much more on our documentation website.

Related

Development WCF server configuration

I am trying to come up with a way to accomplish something but haven't been able to find what I am looking for yet.
4 Developers
1 Development webserver
1 Development WCF server
We each have our own website for testing/debugging on the one server using IIS6. We each have our own port number that distinguishes what site we are connecting to.
When our websites make a request for the WCF server the hosts file on our dev webserver points it at our dev WCF server. Likewise, the production webserver's hosts file points it at our production WCF server. This way we never have to worry about changing the Address of our service references in Visual Studio.
Recently we have a need for multiple developers to be working on multiple branches of the WCF code at the same time. Currently we have to take turns using the WCF server.
We want the ability to have our individual websites on the dev webserver point at individual WCF websites on our dev WCF server.
I have tried several ways I thought of but they all require us to update the Address in the service reference in Visual Studio. (currently if we update/add a service call we point our local machine's host file at the dev site after the new WCF code has been deployed to it.)
Does anyone have any idea, or a direction of where I can find common configurations for this type of thing? I have to assume that Microsoft has a best practices setup for multiple developers with multiple dev environments for websites and WCF sites.
Requirements of the setup:
We only get a single webserver for website testing.
We only get a single webserver for WCF testing.
We need a solution that doesn't require us to update the Address in the service reference in Visual Studio when developing on the WCF code.
If worse comes to worse we may have to think about changing the requirements.
Thank you in advance!
You can simply change the address of the service in configuration file for each deployment. You don't need to change the address of service reference until the service has changed in the way that would produce different client proxy code.

Regarding wcf service hosting

i am new in wcf and started learning. i got one confusion like that i create a small wcf service and just do not host it in IIS,console apps or win service but from another apps i can add the service reference of svc file and found it is working. if wcf can work without hosting in any place like "IIS,console apps or win service " then why people would alway host wcf service in IIS,console apps or win service. can anyone tell me the reason.
people use IIS and windows services in general because they are simpler to setup and run more consistently. they can also be hosted more easily on servers where the services can be configured to start automatically, and as usually wcf is used as a server communication method it is usually this that you want to do.
hosting in console applications is generally easier to setup for simple examples for testing purposes, when you want to test your services locally.
Whilst hosting in applications as possible it's a less common scenario to use wcf to communicate between 2 applications on the same machine.
EDIT:
Your original question asked why people always talk about IIS, services etc. The point I was making was that usually wcf is used for web services, and is usually run on a server other than the local machine. Even though it can be used for inter process communication on the same machine this is not the most common use case. This is why you see a lot of examples using IIS and not too many hosting it in a Windows forms app.

Hosting of WCF and Windows Services

My head hurts so much I think I need a bottle of aspirin...
I've created a WCF service and, with help of others from this site and the department I work in, the WCF service is running as a service on my development machine. Tested it with a console app and it works.
But, it's not supposed to be on my development machine. It needs to be on a different server.
This is difficult because the server it is supposed to reside on DOES NOT have Visual Studio installed on it.
So I cannot run the VS 2008 Command Prompt with installutil to run the WCF service as a service on that server.
Broadly speaking, you've got three options, all of which are described on MSDN:
Host the service under IIS
Self-host the service in any managed .NET application
Host the WCF service under a Windows Service
Which one is right for you depends on what your service is for, how it'll be consumed, how scalable and secure you need the set-up to be, and a dozen other things besides. Without knowing a bit more about what your service does and how it'll be used in your organisation, it's difficult to make a recommendation.
IIS hosting is easy to set up and is the way to go if you want to leverage all of the industrial-strength hosting functionality that a full-blown web server offers.
Self-hosting is quick and easy - you can knock out a WCF-hosting console app in two minutes flat - but is the clunky solution. You of course have to run the host application as a particular Windows user. Perhaps not ideal?
Hosting under a Windows service is the middle ground. It gives you that always-available functionality without having to be logged in as a specific user, but doesn't offer the configurability and scalability of the IIS solution. It takes a bit more effort than belting out a quick console app, but not much.
The server that the windows service will reside on will have the .NET Framework. INSTALLUTIL is located in the Microsoft.NET\Framework(version number) folder in the Windows directory.
For example, C:\Windows\Microsoft.NET\Framework\v2.0.50727.
No need to write a console app to host your service now (unless you want to).
You can also host your WCF service under IIS, check this out: MSDN - How to: Host a WCF Service in IIS. It really is just a five minute job :)

How do I deploy a WCF service library to WAS?

I have created a WCF service library (not a WCF service application).
The project output is a dll.
How can I host this on IIS 7.5/WAS?
I believed that creating a service library was the way to go so that it could be used on a variety of hosts, whereas the service application is limited to IIS.
I'm getting lost in MS mumbo jumbo here, so I'd appreciate any help on getting this service deployed.
Thanks!
Edit
I got the service hosted by following these instructions:
http://msdn.microsoft.com/en-us/library/ms733109.aspx.
It seems like there has to be a better way to host service libraries. Deployment shouldn't require taking settings from app.config and moving them into web.config. Is it standard to wrap them in service applications? Is that even possible?
How are other people handling this?
Yes, creating separate library is good practice because hosting code is not coupled with your services. But you still have to write a host. In WAS, host is in a Web application. To host service in WAS you have to create .svc file and configuration for each service. That is the reason why you have to copy configuration from app.config to web.config. In .NET 4.0 this can be simplyfied with configuration based activation (no .svc is needed) end default endpoints.

Hosting requirement: What does WCF need to work?

I plan to start developing with WCF this weekend. Before i get too far along, I'd like to know what I need from my web host? What does our server need to run to enable WCF? Is it standard ASP.NET 3.5 SP1 stuff? Does the host need to do anything to our IIS configuration?
I'm currently hosting our ASP.NET apps, company website, etc. with a third party hosting service. Due to our size, cost, etc. we are using a shared hosting plan and have somewhat limited access to chanign IIS. I'm hoping we don't have any problems that would limit our ability to use WCF.
If you want to host your WCF service in IIS, you need IIS6 (Win Server 2003) or preferably IIS7 (Win Server 2008), the .NET 3.0 (or preferably: .NET 3.5 SP1) framework, and the ability to create virtual directories in IIS (so yes, you need at least some degree of IIS configurability).
That's it! :-)
Marc
You have several options:
You can host in IIS6+ using ASP.NET: simplest, offers integration with ASP.NET runtime (can be disabled to reduce overhead if not needed, imposes requirements on endpoint URLs, restricted to HTTP[S] as transport, all the benefits of IIS worker process management
You can host in IIS7+ using Windows Activation Services (WAS): more advanced, complete control over endpoint URL, can use any transport (TCPIP, HTTP[S], MSMQ, NamedPipes), all the benefits of IIS worker process management
You can host in a custom Windows Service: all the power of WAS except worker process management and you must write your own windows service and you have
For more information, check out this section of the MSDN documentation.