It seems like there is tens of posts in the internet with such error. But I think my case is different, and all solutions I found do not help me.
I have type (I deleted all unimportant things but it changes nothing):
public class MyClass
public ExternalLibrary.ExternalType myVar;
As it turned out the
ExternalLibrary in question was built for AMD64, while the project using it was targeting any CPU. The compiler couldn't find the class when building the project for 32 bit processors, hence the error. You can safety switch to targeting 64 bit processors, since it won't work on other machines anyway. To switch the target processor go Build -> Configuration Manager -> Platform -> x64
You may want to choose a different combination of platform for each of your projects depending on active solution platform. For example, if your solution is targeting x86, project A builds for x86, while project B for any CPU, but if the solution's targeting x64, both projects A and B build for x64. For more information see Understanding Build Configuration.
If you're playing with these settings you may end up with an unexpected configuration, so it may make sense to have a look at what each project's targeting (you can do it in the Configuration Manager).