C# type defined in an assembly that is not referenced

后端 未结 7 1260
梦毁少年i
梦毁少年i 2021-01-01 23:00

I have two projects A and B. Project A makes use of type X in project B, so I have a reference to B added in A. Everything built fine.

I signed project B using a s

相关标签:
7条回答
  • 2021-01-01 23:32

    You could try editing the project A's project file (projectA.csproj). To do this through visual studio right click on the project->unload project and then on the unloaded project right click->edit file. Search for the reference to project B in there, and try to correct as necessary

    0 讨论(0)
  • 2021-01-01 23:35

    What worked for me was to remove the reference to the project, then add it back in again. A new error message appeared stating that I needed a reference to a third library that was missing, so the original message was a bit misleading!

    0 讨论(0)
  • 2021-01-01 23:41

    To help people getting here from Google, Merlyn's comment asking about delay-signed was the answer for me.

    I was getting this error referencing a delay-signed assembly A that referenced a type X defined in assembly B. I got the error that B wasn't referenced (and I was already referencing the signed version of B).

    The fix was to find and reference the signed version of A.

    0 讨论(0)
  • 2021-01-01 23:45

    This also happened to me.

    In my case, the problem was that from a solution A I was referencing projects from a solution B (I changed the name of a project from B). When I tried to compile A, it tried to find the old name of the project in B.

    I added again the new reference of this project, recompile and so on but unhopefully it did not work.

    The problem was fixed when I added again all the reference of B in A. I was loading old DLLs that were compiled with the old project of B. These DLLs had some kind of cross interaction with the old reference.

    I hope this work for someone else.

    0 讨论(0)
  • 2021-01-01 23:47

    Based on what you said in the comments, I would say it's most definitely something up with Project A.

    Perhaps these steps will help fix it:

    1. Remove the reference to project B and save
    2. Crack open the .csproj file with notepad or something
    3. Look for any references to Project B in there (maybe a hintpath node) and remove the node.
    4. If Project A happens to be an ASP.NET project, look in your web.config or your aspx page headers for any references to Project B.

    Once you remove all references to the project, reload the project as bottlenecked suggested and see if that fixes it for you.

    0 讨论(0)
  • 2021-01-01 23:47

    Sorry for late answer, but this helped me:

    (Assuming that you have AnyCPU solution platform currently)

    • switch solution platform to x86.
    • compile
    • switch back
    • compile again.
    0 讨论(0)
提交回复
热议问题