Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS0579 - Duplicate 'System.Reflection.Assembly[something]Attribute Errors #29

Open
believelifeisfun opened this issue Apr 30, 2020 · 5 comments

Comments

@believelifeisfun
Copy link

Hi Scott,

I'm enjoying the instruction, but I must have missed an instruction, or "fixed" something I should not have fixed along the way through your ASP.Net Core lesson, but I've run upon this CS0579 error twice now getting up to section 3.8 "linking to the details."

The first time I ran into this error, I was able to add a series of "false" <GenerateAssembly[something]Attribute> statements to the .csproj file and the duplication error cleared itself. The errors started popping up again around section 3.8 and even though I back out of the changes for several modules, I keep getting the error.

Originally I thought the problem was caused because I created the OdeToFood project with the target framework of ".Net Core 2.1" and then failed to do the same for the "OdeToFood.Core" and "OdeToFood.Data" projects. And I switched all three to 2.1, and then to 3.1 trying to see if there was some reason why the compiler is trying to build these assemblies multiple times. Setting the "generate" flags to false for all of them in each .csproj file doesn't seem to eliminate the errors either.

I'm just going to archive the solution and start over again and not try to be clever by using 2.1, and follow the added instructions for 3.0+ here on github. But, I figured I would pass this along in case others were having the same problem.

Good Fortune,
Richard

@believelifeisfun
Copy link
Author

believelifeisfun commented Apr 30, 2020

Going through the second time, I think I know "where" the issue started. In section 2, "Building a Data Access Service" intellisense is not finding the class "Restaurant" in OdeToFood.Core. The error CS0246: The type or Namespace name 'Restaurant' could not be found (are you missing a using directive or an assembly reference?). Unfortunately it also doesn't offer the option to add the namespace to OdeToFood.Core. I tried adding the namespace manually, but it doesn't seem to see the other project in the same solution.

Note that this is where these reference errors begin.

Good Fortune,
Richard

@believelifeisfun
Copy link
Author

I right-clicked on each project adding project references to both "OdeToFood" and "OdeToFood.Core" in the "OdeToFood.Data.csproj" file. Then I also added a single project reference to "OdeToFood" in the "OdeToFood.Core.csproj" file. I removed the problem line:

IEnumerable<Restaurant> GetAll();

And did a build on the solution. Everything works up to that point. But reading the line above, I can't seem to get this project to use the Restaurant class in "OdeToFood.Core".

Good Fortune,
Richard

@believelifeisfun
Copy link
Author

Note: to move on with the lesson, I moved the files in the OdeToFood.Core and OdeToFood.Data projects into folders under OdeToFood/Pages/.. and now intelisense easily finds the class and I'm able to move on. I would still appreciate any advice about why I couldn't reference the class from the separate projects.

Good Fortune,
Richard

@CePur
Copy link

CePur commented May 5, 2020

Unfortunately, Mr. Scott Allen has passed away recently.

@StayFN
Copy link

StayFN commented Jan 19, 2021

I just ran into the same Problem and needed to reference them manually. Also when trying to add them via Intellisense my Visual Studio went into an (probably) infinite loop.

Solution was also just to right click on the Projects and add the References manually. I think there are some shenanigans going on with IntelliSense.

Rip Mr. Scott

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants