7

Pretty new to C# and Visual Studio. I started with a .exe that needed modification, decompiled it in .NET Reflector, then opened the Assembly in Visual Studio 2015. I have made my change and clicked "Build" and now I get two errors with code "CS0579... Description: Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute" (the second is the same but without 'global::')

I don't have a reputation of 10 yet, so I cannot post my screenshot.

Need to get past this. any Help is welcome. Thanks!

wasjack
  • 85
  • 1
  • 8
  • Have you tried to remove the second TargetFrameworkAttribute? – Camilo Terevinto Dec 08 '15 at 23:33
  • Thanks. Here is the line I think may be suspect, in 'AssemblyInfo.cs' : [assembly: System.Runtime.Versioning.TargetFramework(".NETFramework,Version=v4.0,Profile=Client", FrameworkDisplayName=".NET Framework 4 Client Profile")] How much of it do I need to cut out, and is this the correct spot? – wasjack Dec 08 '15 at 23:39
  • The first error happens if I do Build+Intellisense. If I do Build Only, There is also an error here: Error CS0579 Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute JRUniFlowProLawTransfer C:\Users\\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.cs – wasjack Dec 08 '15 at 23:44
  • Are there 2 AssemblyInfo files? That might be the cause. You should delete the entire line – Camilo Terevinto Dec 08 '15 at 23:45
  • Booya! Here is the Output after deleting the first [assembly:... line: 1>------ Build started: Project: JRUniFlowProLawTransfer, Configuration: Release x86 ------ 1> JRUniFlowProLawTransfer -> I:\Customers\\Source Code\bin\Release\JRUniFlowProLawTransfer.exe ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== – wasjack Dec 08 '15 at 23:48
  • Glad it worked! Please accept my answer so we both win – Camilo Terevinto Dec 08 '15 at 23:53
  • Thanks! I appreciate the swift reply. – wasjack Dec 09 '15 at 01:13
  • Does this answer your question? [Error CS0579 Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute'](https://stackoverflow.com/questions/61997928/errorcs0579duplicate-globalsystem-runtime-versioning-targetframeworkattribu) – Michael Freidgeim Jun 02 '21 at 01:27

3 Answers3

13

You should delete this entire line from AssemblyInfo.cs:

[assembly: System.Runtime.Versioning.TargetFramework(".NETFramework,Version=v4.0,Profile=Cl‌​ient", FrameworkDisplayName=".NET Framework 4 Client Profile")] 
Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
  • 1
    I found on the internet a lot of solutions, but none worked, this one did. A lot of time lost for this error, a lot of answers with the solution proposed by @espumita but those ones didn't worked, more than that raised another errors. This worked like a charm, thank (after 7 years :)) ) – Vali Maties Sep 01 '22 at 16:01
3

I had today the error CS0579 related to some AssemblyInfo and TargetFrameworkAttribute duplicated values. Using sdk 3.1.301 and targetting netcoreapp3.1 and with some other projects targeting netstandard2.1

Using this:

    <PropertyGroup>
        <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
        <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
    </PropertyGroup>

And deleting /bin & /obj fixed my build.

espumita
  • 157
  • 1
  • 6
0

global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute

[assembly: System.Runtime.Versioning.TargetFramework(".NETFramework,Version=v4.0,Profile=Cl‌​ient", FrameworkDisplayName=".NET Framework 4 Client Profile")] 

You can delete line directly from the project. To Delete click and navigate on an error then remove this line, after that build the program and run again.

haldo
  • 14,512
  • 5
  • 46
  • 52