Results 1 to 11 of 11

Thread: [RESOLVED] Specify Target framework for Windows service

  1. #1

    Thread Starter
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Resolved [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?
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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 haha. Even so, have you tried running that and seeing what version it reports?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Specify Target framework for Windows service

    Can we safely assume that .NET 3.5 has been installed on that server?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: Specify Target framework for Windows service

    Quote Originally Posted by jmcilhinney View Post
    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.
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  5. #5
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    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).

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    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.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Specify Target framework for Windows service

    Quote Originally Posted by Edneeis View Post
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    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.
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  9. #9
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [RESOLVED] Specify Target framework for Windows service

    Quote Originally Posted by chris128 View Post
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width