简体   繁体   中英

Windows Service Vs Windows Form Application VB.NET

I'm currently working on a Windows Service Project. I have added a reference to class library which is external from my project,as I need to use a function from that dll .

However, the class library function that I need is taking session values but I cant use those web methods since mine is only Windows. I can only think of two approaches to resolve this issue .

1) Overload that function I need from external class library and replace session values with input parameters. This would definitely be a time consuming process as I have many session values that this function is referring to.

2) I can create a Windows form application instead . Add a web browser control to the form . Configure URL to have all the input parameters that the function in the external project needs. Add a scheduler to run as a background process. In the external project which is coded in ASP.NET which I need to refer to, I can add a new page that takes URL from my windows form app .. parse the query string to get the input values and pass to the required function.

Can you please suggest if any better approach . Thank you !

Option one seems to be the best. It's the tidyest and allows you to keep control of your project. I presume as you start doing this you'll notice patterns that you can exploit so that the total work isn't as much at it looks now.

Shortcuts are seldom short.

I recommend option 1. Option 2 looks like a huge nightmare waiting to happen, whereas option 1 looks like a simple (albeit laborious) code change.

You could make option 1 less painful by doing regular expression search/replaces in Visual Studio or your favourite text editor. I use this technique to make tedious large-scale code changes all the time, it's very efficient once you get used to it.

The long term solution, however, must be to change the library code. Writing re-usable library code that depends on global state is always a recipe for disaster.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM