Re: ASP.net dll as a service
It depends what you want to achieve.P.E. update the same database asp.net uses.
But i'm curious on what exactly you want to do with a standard service and asp.net.
It's not the same as a web service if you are thinking something like that.
Re: ASP.net dll as a service
Hello,
What you have described is a Windows Service, which once installed on your machine, is always running.
An ASP.Net Service is not "always running", however, it can be accessed when requested, on a polling basis. This poll would need to be initiated from the client machine, which some form of JavaScript.
This would allow you to "mimic" the functionality of a Windows Service, although, this solution is far from perfect.
I think sapator is right. If you can let us know exactly what you are trying to achieve, we can try to guide you in the right direction.
Gary
Re: ASP.net dll as a service
Sorry you might have missed the point....I know the differences and I know what I am doing is less than ideal.
so as an interim step rather than deconstruct the app I want to expose the existing ASP.net dll (class) as a service.
So the question is , can this be done, and if so what else do I need to do apart from the code I posted?
As an aside if I run it as a windows service can I still use the same threadpool?
Re: ASP.net dll as a service
Okay, so let me see if I have this right...
You want to take the compiled dll from your ASP.Net application, which has a number of methods, properties, etc, that you want to expose in a Windows Service. Is that right?
You are likely going to struggle to do this, as the compiled dll will have a number of ASP.Net dependencies, that will not exist in the Windows Service. You would need to abstract the common methods etc into a standalone DLL, that has no dependencies on ASP.Net. Once you have that, you could use that dll within both the windows service, and the ASP.Net application.
In terms of sharing the same threadpool, I am not sure on that one.
Gary
Re: ASP.net dll as a service
As it is known, services run on their own threadpool. You will need to use threading to combine if possible the two of them.
Personally i have managed to do so in the past with the help of JMC but it's ok for a simple app but probably i horror for what you are trying.
Anyhow i haven't exactly understood what you are trying but something inside me is repeating "wrong in so many ways,wrong in so many ways,wrong in so many ways,wrong in so many ways"
Maybe a full explanation on what you want will help for an alternative?
You write "Because the project is very simple and I don;t want to over complicate the structure as an interim step", but you are obviously overcomplicated thinks, doing something that is not meant to be done.
Anyway good luck in whatever way you decide to go.
Re: ASP.net dll as a service
Ok so the alternative I have come up with is to migrate the app to another server on iis 7.5 and make use of
startMode="AlwaysRunning"
serviceAutoStartEnabled="true"
serviceAutoStartProvider="InitBackground"
However this gives me an error :
There was an error during processing of the managed application service auto-start for configuration path: 'MACHINE/WEBROOT/APPHOST/XmlGen/'. The error message returned is: 'An error occurred while executing Preload method.
Exception: System.InvalidOperationException
Message: An error occurred while trying to create preload provider 'Business.BackgroundStartup, Business'.
Exception: System.IO.FileNotFoundException
Namespace Business
Public Class BackgroundStartup
Implements System.Web.Hosting.IProcessHostPreloadClient
Public Sub Preload(parameters() As String) Implements System.Web.Hosting.IProcessHostPreloadClient.Preload
' Business.ServiceThreads.Start()
ServiceThreads.WriteLog("Preload ")
End Sub
End Class
<site name="Xml" id="3" serverAutoStart="true">
<application path="/" applicationPool="xml">
<virtualDirectory path="/" physicalPath="C:\home\clients\db\xml\htdocs" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:localhost" />
</bindings>
<applicationDefaults serviceAutoStartEnabled="true" serviceAutoStartProvider="InitBackground" />
</site>
Re: ASP.net dll as a service
I've resolved it. Fairly obvious on reflection :lol:....
App_global.asax.vkpfe1jl, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
System.IO.FileNotFoundException
I hadn't pre-compiled on the testing server therefore the assembly name was not fixed. Added a web deployment project and pre-compiled to testing and it works.
Re: ASP.net dll as a service
Glad to hear that you got it working!
Gary