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 540695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:16:01+00:00 2026-05-13T10:16:01+00:00

We publish a class library that must remain compatible with .NET 2.0. However, we

  • 0

We publish a class library that must remain compatible with .NET 2.0. However, we would also like to use this class library internally for WCF-based projects.

Reading e.g. expose-object-from-class-library-using-wcf brings up an approach for using 2.0 class libraries by creating DataContractSurrogate objects to map 2.0 classes. However, our object hierarchy is rich and deep, and this would be tedious and difficult to maintain.

Since we do control the source code, I’m looking for an easier approach.

One thought is to add the DataConract attribute to the source code, and provide an “empty” implementation of DataContractAttribute when the solution is built targeting the 2.0 runtime, and using the System.Runtime.Serialization implementation when the solution is built targeting 3.0 and newer runtimes. This could be accomplished by manually tweaking references between builds.

Is there a better way to implement this approach?

Is there a better approach?

  • 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-13T10:16:01+00:00Added an answer on May 13, 2026 at 10:16 am

    An alternative approach it to add the WCF attributes (DataContractAttribute etc), and build with the .NET 3.0 assemblies.

    When you run the application under .NET 2.0, having attributes from an assembly that is not available at runtime won’t normally cause a problem.

    (You would get an error if you actually try to access the attributes, but that is unlikely and easy to avoid).

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

Sidebar

Related Questions

I want to use the Publish.GacRemove function to remove an assembly from GAC. However,
if i decide to use the 'publish' option for my ASP.NET website, instead of
I am trying to publish an Asp.net MVC web application locally using the NAnt
When I publish my ASP.NET site in RELEASE mode, and set compilation debug=false, will
I want to know how to simply publish over http = much like Mercurial
Every time I publish the application in ClickOnce I get get it to update
What causes the publish error: fl.getDocumentDOM() has no properties ? The error occurs only
Any time I try to publish my Portal project on a Websphere Portal 6.1
I want to show the publish date in the About dialog.
any idea which is the command for publish in msbuild corresponding to the one

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.