0

I'm developing a .NET application in C# (.NET Framework 3.5 console application) using Visual Studio 2010. (Win7 64bit) After a machine crash, I copied my project from the old HD to the new one. Now on the new machine, whenever I build, I get the error message:

The type 'Bloomberglp.AppPortalApi.DataPersistence.ExtensibleDataObject' is defined in an assembly that is not referenced. You must add a reference to the assembly 'Bloomberglp.AppPortalAPI, version=1.3.5.1, Culture=neutral, PublicKeyToken=51f5d93763bdb58e'.

It's attached to the definition of the first method in the "Program" class, which obviously doesn't mention it.

However, I'm not using this type anywhere in my project, and none of the references in my project are using it either. I had used it previously, but all references to it have been removed...so I thought. I searched for it but can't find it in any of the .cs files. It's not findable in the Object Browser either. So where/how should I be looking for it?

Edit: Found C# type defined in an assembly that is not referenced ; there are no references to the the type or the dll in the .csproj

Switching my target between x86 and any cpu and recompiling had no effect, nor did switching back.

Community
  • 1
  • 1
AnotherParker
  • 789
  • 5
  • 16
  • If it doesn't exists in your .csproj file it is weird ... try go to Build menu -> Batch Build -> 'Select all' button then click Clean. Check output window. You suppose to see "========== Clean: X succeeded, 0 failed, 0 skipped ==========" After that reBuild the solution. I hope it helps! – Pavel Kovalev Dec 31 '12 at 22:49
  • Sorry @PavelKovalev -- that has no effect, still the same error message. – AnotherParker Dec 31 '12 at 22:52

1 Answers1

2

This is typically an indirect reference. In other words, you reference an assembly that's already built and that assembly references a type in the "phantom" one. So you won't see it at all in your project file. You'd see in the project that built that assembly, certainly some odds that you lost that one due to the crash or just forgot to copy it.

Another classic way to get this problem is by targeting the Client profile, a scourge of VS2010 that selects it by default. If an assembly references a type from an assembly that isn't part of the Client profile, like System.Web, then it the compiler gets stoopid when the assembly is rejected because it needs an unavailable .NET framework assembly. You get a warning about it, but that's easily ignored when you focus on the error. Otherwise a good match with the kind of business that Bloomberg is in, it is a webby company. You fix that one by changing the framework target to the full one.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • *sigh* suspected as much. How do I go about finding which reference has a ref to the phantom type? – AnotherParker Jan 02 '13 at 02:44
  • Solved the problem by making up fake types with empty methods for each of the external types used from each reference. ARGH. Wish there was a better way. – AnotherParker Jan 03 '13 at 19:19