Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6596943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:08:40+00:00 2026-05-25T18:08:40+00:00

I hope this is a very easy one to solve. I have a crypto

  • 0

I hope this is a very easy one to solve.

I have a crypto library that will be used for NET1.1 apps and higher. The X509Certificate class is in NET1.1 and X509Certificate2 is in NET2.0 and above.

I want to do something like:

#if NET1.1
public void LoadKeys(X509Certificate cert)
{
....
}
#else
public void LoadKeys(X509Certificate2 cert)
{
....
}
#endif

What I’m missing is the compiler symbol!

I found that NET20, NET30 and NET40 exist. However I want to do “if NET1.1, do this; otherwise, go with the advanced model”.

Also, bonus question :), do I have to compile in NET1.1 and NET2.0 separately for this to work as intended?

Or can I compile the DLL in NET1.1 and then put in a machine with only NET2.0, and hopefully the ILM will go to the new framework?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:08:41+00:00Added an answer on May 25, 2026 at 6:08 pm

    Your code already does what you want – if there’s no “NET1.1” symbol defined, it will use the second piece of code.

    And yes, you have to compile separately for 1.1 and 2.0 for this to work, because you’ll end up with different results – one will end up with only the first overload; one will end up with only the second overload.

    You probably could run the 1.1 code in 2.0 and higher – that’s the normal case – but as you can’t have a single build which contains both versions of the method and is 1.1-compatible, you might as well use two builds.

    One option is for both methods to appear in the .NET 2+ build though, to retain backward compatibility for apps originally built against the 1.1 build which want to migrate:

    public void LoadKeys(X509Certificate cert)
    {
    ....
    }
    #if !NET1.1
    public void LoadKeys(X509Certificate2 cert)
    {
    ....
    }
    #endif
    

    EDIT: Just to clarify a few points from the discussion with Artur in comments:

    • Artur’s blanket statement that you can’t use a .NET 1.1 in a .NET 4 application is definitely wrong. I’ve just done so with the .NET 1.1 build of NUnit (which was the simplest .NET 1.1 library I had to hand)
    • If you’re relying on Code-Access Security then there have been changes there between framework versions; you’d have to look at the details of what you’re doing to see whether the differences are significant
    • You can’t build a .NET 2 assembly and run it in .NET 1.1 due to binary format changes – it’s only the other way round that works.
    • While it’s possible that you’re relying on a call in .NET 1.1 which has been removed from a later version of .NET, that’s a pretty rare case, and should be reasonably easy to determine. In general Microsoft tries to maintain backward compatibility pretty well.

    You might also want to read the .NET 4 Migration Guide.

    Finally, I’d point out that .NET 1.1 is really old now – if you know you need to support it, then that’s fair enough, but personally I’d try to get clients to upgrade if at all possible 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm stuck in this very easy problem (I hope it is for you). I
This is a very strange problem, and I just hope that I can clearly
hope this will be a quick easy question, I've just tried my app on
I hope the below task will be very easy for sed lovers. I am
I hope this is an easy one, but I've got a page where there's
I hope this is a very simple question (I'm only using bootstrap since today),
I'm not a a very experienced Windows developer, so I hope this all makes
This is a very hard to explain question and I hope my code extract
Quite new to this but i have created a SQL script that groups by
Sorry friends if this question is very easy but i am confuse i unable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.