1

I'm using 2 .NET frameworks in a solution. I've copied code over from an example app into my primary app and I'm trying to make it work as it before attempting to migrate the code in the example app to the version of my primary app. I'm currently getting the following error from one of my files:

"Error CS0433 The type 'QueryStringMapping' exists in both 'System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'System.Net.Http.Formatting, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'"

I think this can be fixed by putting the following code at the top of the code file:

// CS0434.cs
// compile with: /r:cs0434_1.dll /r:cs0434_2.dll 

I'm making this conclusion based on the following url:

https://msdn.microsoft.com/en-us/library/c8td0be1.aspx

There is only a single Formatting.dll in my bin with version 5.2.30128.0. How would I write the header code to resolve this error based on the details that I've provided?

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
user7242966
  • 347
  • 1
  • 10
  • 1
    Note: code comments in MSDN samples are generally addressed to developer (like in this case). There are no magical comments that compiler will look at and change its behavior. – Alexei Levenkov Feb 03 '17 at 17:43
  • Can you also clarify what "I'm using 2 .NET frameworks in a solution" means? Is posts correctly tagged as .net and asp.net-core ? – Alexei Levenkov Feb 03 '17 at 17:48

1 Answers1

2

You want to add a reference with a specific version. Check out this post.

How exactly does the "Specific Version" property of an assembly reference work in Visual Studio?

Community
  • 1
  • 1
John Brandli
  • 110
  • 4