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

  • SEARCH
  • Home
  • 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 would like to publish a website using msbuild. Since I have a website
I'm debbuging a web application that has a WebSite and a class library containg
I have to create a publish-subscribe silverlight application. and the class that publishes the
i've made a Class Library project for Asp.Net applications, consisting in some classes plus
I have two projects: ASP.Net 3.5 website (frontend, UI) VB Class Library (dataaccess logic)
I would like to produce a list on the side of my blog that
I'm developing an WPF application that has an reference of a C# Class Library.
I created a class like this public final class MyView extends View { public
We use boost - so using that library should be fine. But I've never
I have a class library that attaches itself a tiny SQL Server database that

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.