Assembly '' is incorrectly specified as a file.

Posted: 2008-07-02 in .Net
Tags:

Assembly ‘<assembly>’ is incorrectly specified as a file.

I came across this error today, my situation was quiet easy, I added 5 dlls of external dlls and the proceeded to reference them. Done this a thousand times before including the exact same dlls for the client of the client server project…. No problems on that one.

This time, there was a problem, baffled and a little stumped I tried rebuilding several times, complete cleans, re-referencing, no referencing and so forth. All no solution. Eventually I called on more experianced help and all tried the same things all were baffled.

Finally an idea dawned on me, the folder that I was using to contain the dlls was named “Includes”, I renamed this to lib (talk about old school) and the errors went away.

So as stated:

Fix: Dont call the containing dll folder “Includes” as it seems to be reserved…. and no this wasn’t a web project it was windows application project.  (Author note: This fix doesn’t work please keep reading)

—————- UPDATE —————-

AGGGGGGGGG Assembly ‘<assembly>’ is incorrectly specified as a file  strikes back! its seriously killing me! time I don’t have is being wasted on it… hummm don’t ask the question why are you updating your blog then? anyway….

This time I tried something else, this time I set the build action to none and copy if newer for each of the dll’s generating this warning.
It seems to have gotten rid of the warnings plus the program still compiles and runs (with complete directory clean).

Anyway no idea why, plus the MS site is pretty well useless. Post a comment if you have anything else to add.

Fix.  Set the build action to none for the assembly.

Cheers

Choco

BTW Only eat farmed fish, won’t be long till the bottomless pit called the sea isn’t so bottomless.

Advertisements
Comments
  1. Bleh says:

    I ran into this problem today. Never seen it before. When I found the build action solution you proposed it is all clear: normally, I never have thrid-party included in the project, they are simply referenced to a location elsewhere.

    If they ARE included in the project, as they were today (mostly by convenience as I was working on a POC) build action should be set to none, of course, since the dlls are already built!

    Dont know if this is exactly the same problem you are describing but I thought I should share.

    Regards

  2. Smorg says:

    I’ve recently noticed this error coming up but I’m pretty sure I know why, just not sure on how to fix it.
    My problem’s caused by having a reference to a system wide assembly (one I added to Tools > Choose Toolbox Items) which I have subsequently added using the ‘Add Reference’ option on the project and pointing to another copy of the assembly / dll.

  3. Flo says:

    Thanks a lot for your post !! It helps me.
    Work fine with Set the build action to none for the assembly.

  4. tom says:

    Thank you for your tip, it helped me.

  5. If you set the built action to None then the file won’t be included when you publish the project.

    • Choco Smith says:

      “If you set the built action to None then the file won’t be included when you publish the project.”

      You should set the file to “none and copy if newer”, so if you publish it should be in there. When this issue popped up i emptied the bin folder complete to check this and the files did appear.

      I don’t know the exact reason for the error but i suspect a change of the assemblie’s guid during compile time.

  6. David Hamdan says:

    Thanks for the post! This resolved my issue as well. My app is:

    * Visual Studio 2010 (.NET Framework 4.0)
    * WPF based application
    * ClickOnce Deployed

  7. David says:

    Set Build action to none fixed it for me.

  8. CS says:

    Could someone please tell me how to “Set Build Action to none”?
    Many thanks for any replies!

    • Choco Smith says:

      it should just be as simple as right clicking on the dll causing the issue (under references) and selecting properties.
      Then in one of the property window fields find the build action drop down. choose none.

  9. Yan says:

    the problem has been driving me nut for couple of day. Finally find the solution here. For me, I used third party dll. Choose build as none and copy if newer solved the problem. thanks a lot!

  10. Brendan MacLean says:

    You do need to set to “Content” if you want the file to be included when you Publish for ClickOnce installation, as Kurian points out. This is different from being copied to the bin folder. Many things get copied to the bin folder that aren’t included when installers are published (e.g. .pdb files unless you explicitly include them). You can check this on the Publish tab for the application. Click the “Application Files…” button before setting Build Action to “None” – you should see the file listed – and after – you will see the file removed from the Application Files list.

    Sure wish there was a solution to the warning that allowed you to include DLLs and EXEs during publishing of ClickOnce installers, other than adding them to References. These are not necessarily things I want to ever load into my application’s process. The EXEs I just want my application to run.

    But, I still get this obnoxious warning… Would love to hear of a solution.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s