Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile c# csproj into exe in Visual Studio 2015 - error CS0579

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!

like image 313
wasjack Avatar asked Dec 08 '15 23:12

wasjack


People also ask

What is the command to compile C?

Run the gcc command to compile your C program. The syntax you'll use is gcc filename. c -o filename.exe . This compiles the program and makes it executable.

How is C compiler compiled?

Usually, a first compiler is written in another language (directly in PDP11 assembler in this case, or in C for most of the "modern" languages). Then, this first compiler is used to program a compiler written in the language itself. You can read this page about the history of the C language.


2 Answers

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")] 
like image 78
Camilo Terevinto Avatar answered Sep 23 '22 00:09

Camilo Terevinto


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.

like image 28
espumita Avatar answered Sep 24 '22 00:09

espumita