开发者

The type "x" is defined in an assembly that is not referenced. VS 2010 C#

I am having a problem I just couldn't solve and would like some input.

I am working with multiple class libraries in Visual Studio 2010, .net 4.0 Framework, in C#. I have a class library project which references the assembly output(.dll file) of another Visual Studio solution. The reference was added correctly to the cl开发者_如何转开发ass library project (correct path, version, etc.). All types dependant on the referenced assembly are known by the compiler at design time (no red squiglies).

However, when I attempt to build the project I get the following error:

The type 'x' is defined in an assembly that is not referenced. You must add a reference to assembly 'MyAssembly, Version=1.0.1.1, Culture=neutral, PublicKeyToken=null'.

Note: type name replaced by x above.

It is as if the reference has not been added, but it has. Has anyone else encountered a similar problem and discovered a work around?

Thanks so much, Andrew


Thats a weird one but it should be agnostic to Version i.e its also applicable to VS 2005 and VS 2008.

  1. Just do some basic testing, if you access to the solution that produces the library file, the .dll file, then scope the solution and have a gander at some of its members.
  2. Then in the project of your own choice, right click on the project and click on add reference.
  3. browse to where the .dll is dumped, under a bin folder and click o.k to add.
  4. VS typically will show some breif animation showing its added something.
  5. Save.
  6. scope in the namespace of the library if you want, VS will automatically pick this up for when press tab after the '=' in an assignment statement.
  7. In a sample class file, instantiate some of these types found only in the .dll file that you have just added. VS studio will start marking up the keywords and etc like normal, which means the reference is working as intellisense is picking up on the new types.
  8. Once you have instantiated a type or a class found in your .dll, test instance by using '.' notation and seeing what information intellisense pulls back from the meta data atatched to the class file.
  9. You should find all relevant data members will populate of the type being probed.

I just tested this like 5 mins ago just to make sure in VS 2008 Pro Edition using .Net 3.5 and C#. NO PROBLEMS MATE !!!

Just try following them steps and trouble shoot things as you go along as I made them steps before testing them and they still worked exactly fine afterwards when i did test them :p.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜