1

I'm trying to target multiple .net framework versions with the built in preprocessor directives but i can't debug the targeted version of my code because that part of my code is cannot be hit during debug.

Here's my code:

   private static void WriterTask(string processName, byte[] byteArray)
   {
#if NET_46
        Task.Run(() =>
        {
            FileWriter(_path, processName, byteArray);
        });
#elif NET_35
        FileWriter(_path, processName, byteArray);
#endif
   }
3
  • How are you trying to run this? are your symbols being loaded and are which version of the framework is this being built \ run in? Commented Jun 11, 2020 at 20:33
  • I was trying to run it in debug mode and it was built by targeting framework version 4.6. Commented Jun 11, 2020 at 20:47
  • 3
    you need to change the project to use NET 3.5 temporarliy Commented Feb 8, 2022 at 16:55

1 Answer 1

1
+50

If you are debugging an application via Visual Studio, you need to check the framework version you are using to launch it. The corresponding setting can be found in the launch button dropdown.

Here is how this setting looks like in VS2019 for my application, which is targeting both .NET Framework 4.5 and .NET Core 3.0: enter image description here On the screenshot, the .NET Framework 4.5 is selected, but I can switch to .NET Core 3.0 by selecting the corresponding item in the menu.

My application contains a few #if NET45 sections, and they can be debugged properly in this case.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.