none
Targeted framework problem RRS feed

  • Question

  • Hi! I'm working on a Windows Forms Visual C++ application. As I'm using Visual Studio 2008, it started targeting Framework 3.5, but now I have selected on the project options to target Framework 2.0. I'm pretty sure all the components I'm using only need 2.0, but when I compile it and try to run on other computers (I've tried one with Vista and one with XP) it doesn't work, but it works if I install Framework 3.5. I would like to know which could the problem be here as this make no sense for me.

    Thanks a lot in advance!
    Saturday, December 20, 2008 4:14 PM

Answers

All replies

  • When you target .NET 3.5 VS2008 let you use .NET 3.5 features and adds the relevant references but still build to .NET 2.0 because the CLR(common language runtime) is still 2.0.  So if you want to run your code in only .NET 2.0 you need to target 2.0 so VS2008 will not let you use .NET 3.0 and 3.5 features in your application.

    Why 2.0 build option because WCF, WPF, WF I think build to 3.0 or 3.5 because all are defined in .NET 3.0.  Here is an Asp.net related thread were we do our best to explain this issue.


    http://social.msdn.microsoft.com/forums/en-US/netfxsetup/thread/8da540d4-4615-4842-9f1d-5827bef061ef/

     


    Asp.net MVP, MCPD Web C#, MCTS TFS, MCITP BI and DBA
    Saturday, December 20, 2008 5:14 PM
    Moderator
  • Thanks for the explanation, but as I said, I already targeted Framework 2.0 on the project options, and other computers still need to have installed framework 3.5 in order to execute my application, and that's what I want to solve :) I don't want to force people who have framework 2.0 installed to update it to the last version just to run my program.

    Thanks!
    Sunday, December 21, 2008 12:13 AM
  • ( As I'm using Visual Studio 2008, it started targeting Framework 3.5, but now I have selected on the project options to target Framework 2.0.)

    This means your application is using NET 3.5 just not directly because to use only 2.0 you must target 2.0 during development and I have helped users use VS2008 to develop applications that installs in Win2000 because it only uses 2.0.  So you need to make the needed changes like open each solution and target 2.0 and remove all 3.5 dlls as needed.


    Asp.net MVP, MCPD Web C#, MCTS TFS, MCITP BI and DBA
    Sunday, December 21, 2008 2:10 AM
    Moderator
  • I will try what you say. The strangest part now is that I tried to create a new Windows Forms project, and I targeted framework 2.0 from the creation of the project. I just added two references to dlls, one to the Office Powerpoint interop, and another to a control that just need 2.0. I built the release executable, and it still need framework 3.5 to work. Which of the Windows Forms dlls or the Office dlls would need framework 3.5?

    Thanks for your help!
    Sunday, December 21, 2008 12:01 PM
  • You are not using the correct setting because the thread below the user developed an application that runs in Win2k, XP and Vista by targeting .NET 2.0.  The link below also shows each step to configure targeting in VS2008.

    http://social.msdn.microsoft.com/Forums/en-US/vssetup/thread/44c7f794-3222-4e78-9624-2a673896e5d6/

    http://blogs.msdn.com/lukeh/archive/2007/06/29/net-framework-multitargeting-in-visual-studio-2008-aka-orcas.aspx


    Asp.net MVP, MCPD Web C#, MCTS TFS, MCITP BI and DBA
    • Marked as answer by Figo Fei Friday, December 26, 2008 6:19 AM
    Sunday, December 21, 2008 5:22 PM
    Moderator
  • I have news about this topic. On this blog: http://blogs.msdn.com/kcwalina/archive/2007/10/02/Multi_2D00_TargetingAndFxCop.aspx the owner talks about the exact problem I'm facing. It's something about the red bits and the green bits (he explains it very good). The conclusion is that you may have targeted Framework 2.0 but you might be still using 3.5 features without knowing it, and the compiler doesn't  know it neither.

    So, the guy has built a rule that can be added to Visual Studio so it can detect if you are using something of a Framework different of the one you are targeting. And the program Microsoft FxCop also does that (apart from analyzing all your .NET code). Here one of its creators talks about how to use it.

    Now I have seen that my problem is that in my code I'm using something of the namespace "Microsoft::VisualC::StlClr", but I don't know what (I haven't added it to my project).

    Well, I hope this can help someone with targeting problems!
    Friday, February 20, 2009 11:41 PM