skazantsev / WebApi.Hosting.TopShelf.Demo

Self-hosting ASP.NET Web API as a windows service using TopShelf
20 stars 7 forks source link

Self-Hosting on .NET 4.0 #1

Open Reza-Noei opened 6 years ago

Reza-Noei commented 6 years ago

Hi, I want to develop a windows service which can be installed on windows XP also. so I need to force the application to use .NET 4.0 but it seems that TopShelf Self-hosting is working on .NET 4.5 and i don't know how to downgrade.

I know that it may WebApi2 Prerequisite but i want to do that. is it possible ?

skazantsev commented 6 years ago

Hi @Reza-Noei,

Topshelf 3 can run on .NET 4.0 but seems like ASP.NET Web API 2 doesn't support .NET 4.0 and I don't know any workarounds for this.

You can try some alternative .NET frameworks for building HTTP APIs like Nancy. It supports .NET 4.0 and there's a nice guide explaining how to self-host it. Then you can integrate it with Topshelf 3 yourself or use this handy library.

Another notable alternative is ServiceStack 4.0.*. It also supports .net 4.0 and can be self-hosted.

Hope this information is helpful.

P.S. I used https://www.fuget.org to determine required versions of .NET framework for mentioned packages.

Reza-Noei commented 6 years ago

Thank you @skazantsev,

I was thinking about WCF and It's complexities. but now I have a new way and i will try to learn Nancy and it seems that it can be useful for me.

Kushal5 commented 4 years ago

Topshelf 3 can run on .NET 4.0 but seems like ASP.NET Web API 2 doesn't support .NET 4.0 and I don't know any workarounds for this. Nancy is no longer maintained. Is it still advisable to use?

What if we use Web API 1?