Hosting DataPortal in Windows Service

Hosting DataPortal in Windows Service

Old forum URL: forums.lhotka.net/forums/t/135.aspx


stegerwald posted on Thursday, May 18, 2006

Hi,

what is the easiest Way to host the data portal within a windows service? we dont have the option to use IIS.

How can I achieve this, how big is the implementation effort?

Thanks for any suggestions

Frank

stegerwald replied on Monday, May 22, 2006

any ideas anyone?

probashi replied on Monday, May 22, 2006

If IIS is not an option, how about using Enterprise Services (Host/Proxy) that comes with the CSLA framework!

You can have remoting host in a windows service application but looks like the ‘2005 C# Book’ does not recommend this [ref: page 604, Host Technology: "..I don’t recommend this course of action, because you would need to duplicate a large percentage of IIS to achieve comparable levels of manageability, security, runtime monitoring and so fourth…. "]

stegerwald replied on Monday, May 22, 2006

Well,

thanks for the idea, but

I dont need the features that IIS or Enterprise Services is offering.

I need to install a Windows Service anyhow and so I want to host

the DataPortal there. I am running my application in a workgroup

where I dont need the security features and the management and monitoring

stuff cannot be managed by my customers.

RockfordLhotka replied on Monday, May 22, 2006

I don't recommend writing your own host, nor do any reputable Remoting experts out there.

But if you must, you must. And it isn't hard to do. In its simplest form you just need to write one line of code to configure remoting from your app.config file and you are done.

I wrote some articles on how to do this a few years ago for the Adventures in VB.NET column on MSDN. Those articles have slowly been buried in the huge volume of stuff on msdn.microsoft.com, but if you google for "msdn lhotka remoting" you should find them.

Also, look at Ingo Rammer's remoting book.

Just be aware that a custom host can't handle the volume of either IIS or COM+ - the threading and memory management features of those hosts simply won't be available to you. Also, make sure (and I don't know how to do this) that you get the garbage collector running in server mode, not client mode, or you'll have sporadic perf issues and possible runaway memory consumption. It may be that this is automatic in .NET 2.0 - but it wasn't in 1.1...

stegerwald replied on Thursday, June 01, 2006

Hi,

i have problems implementing my custom remoting host.

It is a simple windows service that does the following:

// Setup Remoting

String filename = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

RemotingConfiguration.Configure(filename, false);

 

Based on the following Configuration file:

<system.runtime.remoting>

<application>

<channels>

<channel ref="http">

<serverProviders>

<provider ref="wsdl"/>

<formatter ref="soap" typeFilterLevel="Full"/>

<formatter ref="binary" typeFilterLevel="Full"/>

</serverProviders>

</channel>

</channels>

<service>

<wellknown mode="SingleCall" objectUri="RemotingPortal.rem"

type="Csla.Server.Hosts.RemotingPortal, Csla"/>

</service>

</application>

</system.runtime.remoting>

 

the client uses the following configuration file:

<appSettings>

<add key="CslaDataPortalProxy"

value="Csla.DataPortalClient.RemotingProxy, Csla"/>

<add key="CslaDataPortalUrl"

value="http://proentfstnb/RemotingHost/RemotingPortal.rem"/>

</appSettings>

 

When I run the client, I get the following Error when trying to get a

BusinessObject via the data portal:

System.Runtime.Serialization.SerializationException

{"The input stream is not a valid binary format. The starting contents (in bytes) are: 53-79-73-74-65-6D-2E-52-75-6E-74-69-6D-65-2E-52-65 ..."

in DataPortalClient.RemotingProxy.Fetch()

It seems that the Call does not reach the server at all.

Any Ideas what I am missing there or what went wrong???

Thanks for any help

Frank

RockfordLhotka replied on Thursday, June 01, 2006

You should probably provide an explicit port number on which the server will listen - for clarity if nothing else.

You should be able to ensure that the server can be reached at all by using your browser to navigate to the server url with "?wsdl" stuck on the end - so ending in ".../RemotingPortal.rem?wsdl" - the result should be a bunch of XML.

stegerwald replied on Thursday, June 01, 2006

thanks, that worked, the server is reachable.

And the problem disappered???

I dont know exactly what happended, but I suspect a version mismatch between the BO dll on the server and the client...

I recompiled the business dll and redistributed the dll and now the

error message is gone.

Thanks for the help

greetings

Frank

 

Copyright (c) Marimer LLC