59

I've added a reference to the log4net assembly dll to my project.

When I build I get a warning saying:

Warning Assembly 'Lib\log4net.dll' is incorrectly specified as a file.

I look up the help for this error on MSDN, and it says:

This warning is generated during application manifest generation when the build process detects that a file reference is actually a (managed or native) assembly.

This is exactly what I'm doing; the file reference is an assembly. What am I being told here?

How do I add a reference to an assembly dll, while not adding a reference to an assembly dll?

meJustAndrew
  • 6,011
  • 8
  • 50
  • 76
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219

2 Answers2

109

Try setting the Build Action property of the source DLLs to None. It solved the issue for us.

  • 2
    We have our log4net.dll at root level in the WinForms project. I followed your advice and set the Build Action to "None". Then I added the file as a reference and was able to successfully build and publish the project using ClickOnce. – proudgeekdad Jun 24 '09 at 23:32
  • 9
    For those who don't from where --> Right Click the dll file --> Properties --> Select "None" from the Build Action menu. – usefulBee Nov 14 '13 at 20:55
  • 2
    This causes the error to go away, but it introduces a whole different problem when deploying the application - the files with build action `None` will not be deployed with the rest of the project... – dub stylee Nov 25 '15 at 23:43
  • @dubstylee you have to set the 'copy to output directory' to either 'Copy if newer' or 'Copy always' – dstnrgrs Aug 14 '20 at 20:47
7

I was running into this problem myself.

This is what worked for me:

I had added an assembly as a reference and as an "Existing Resource." Deleting the file from the Solution Explorer, closing, then reopening the project worked.

jadelane
  • 71
  • 2