[RESOLVED] Specify Target framework for Windows service
Ok, so I have built a Dll and a Windows Service in vs2010. Both are targeting the .net 3.5 framework, but when I install it on the server it installs fine, but for some reason it targets the 2.0 framework and any time the methods fire that are using linq it crashes out with a clr20r3 error system.nullreferenceexception. Not really sure why it's not targeting .net 3.5. Anyone else had any issues with deploying a .net 3.5 service on Server 2003?
Re: Specify Target framework for Windows service
Try using the code in this thread http://www.vbforums.com/showthread.php?t=590709 and run it against the service exe and dll files that you are deploying to the server - what version does it report them as targetting?
EDIT: Oh I just realised it was you that posted the code in that thread :D haha. Even so, have you tried running that and seeing what version it reports?
Re: Specify Target framework for Windows service
Can we safely assume that .NET 3.5 has been installed on that server?
Re: Specify Target framework for Windows service
Quote:
Originally Posted by
jmcilhinney
Can we safely assume that .NET 3.5 has been installed on that server?
Yes 3.5 is installed on the server. I can run the same code in an exe but when I add it to my service and install it, it crashes out with the .net 2.0 clr error that I posted above. I am in the process of trying to do it in vs 2008 because I have found 2010 Beta 2 to be pretty buggy. I'll post again after I test my 2008 version of the project.
Re: Specify Target framework for Windows service
So it works fine on your machine, but crashes on the server? Is there something different about the server? Is 64 bit? (I don't think that would cause a problem, but that may be different than your dev environment).
Re: Specify Target framework for Windows service
You should look into the NullReference Exception. I don't think it is the framework that is causing that it should be coming from your code.
Re: Specify Target framework for Windows service
Quote:
Originally Posted by
Edneeis
You should look into the NullReference Exception. I don't think it is the framework that is causing that it should be coming from your code.
I'd be inclined to agree. .NET 2.0 is the core of .NET 3.0 and 3.5 and soon to be 4.0 as well. They each build on what went before. Your exception is probably just being thrown in part of the Framework from version 2.0. .NET 3.5 is mostly just LINQ.
Re: Specify Target framework for Windows service
Ya you guys were right. I got it working tonight, wasn't the framework that was the issue. I was just thrown off by the cryptic clr error. I found the null reference. I had a synchronizationContext in the dll for raising events from a background thread and as it would seem in a service it is null when you call Current. Makes sense now that I found it, just didn't realize it until some debugging. It is up and running smooth now.
Thanks, I'll close this one out.
Re: [RESOLVED] Specify Target framework for Windows service
So does that mean services cant use SynchronizationContext at all then? I mean I know the main use for that is for marshalling things to the UI thread but surely its still useful in other scenarios where you dont have a UI as well?
Re: [RESOLVED] Specify Target framework for Windows service
Quote:
Originally Posted by
chris128
So does that mean services cant use SynchronizationContext at all then? I mean I know the main use for that is for marshalling things to the UI thread but surely its still useful in other scenarios where you dont have a UI as well?
As far as I'm aware the type of application should be irrelevant. There should be a SynchronizationContext instance associated with every thread in every application, so Current should always return that instance. That said, I haven't tested that extensively.
Re: [RESOLVED] Specify Target framework for Windows service
Yeah that is what I thought - I know I've used it in a WPF app and a console app before when working with WCF but I dont think I've ever used it in a windows service... the console app was just a prototype for what will later become a windows service though so I sure hope there is a way to make it work in a service.