c#引用错误

clear.gifclear.gifclear.gif

Visual C# Reference: Errors and Warnings

Compiler Error CS0012Processing

Error Message
The type 'type' is defined in an assembly that is not referenced. You must add a reference to assembly 'assembly'.

The definition for a referenced type was not found. This could occur if a required .DLL file is not included in the compilation. For more information, see Add Reference Dialog Box and /reference (Import Metadata) (C# Compiler Options).

The following sequence of compilations will result in CS0012:

Copy Code

// cs0012a.cs
// compile with: /target:library
public class A {}

Then:

Copy Code

// cs0012b.cs
// compile with: /target:library /reference:cs0012a.dll
public class B
{
   public static A f()
   {
      return new A();
   }
}

Then:

Copy Code

// cs0012c.cs
// compile with: /reference:cs0012b.dll
class C
{
   public static void Main()
   {
      object o = B.f();   // CS0012
   }
}

You could resolve this CS0012 by compiling with /reference:cs0012b.dll;cs0012a.dll, or in Visual Studio by using the Add Reference Dialog Box to add a reference to cs0012a.dll in addition to cs0012b.dll.

我碰到这个错误是因为用到了一个类中的静态方法,而该类又实现了一个借口,而我又没有引用该接口。

解决办法很简单,在vs里面添加对接口的引用就可以了。就像上面所说的,根本问题在于类的连环引用。

转载于:https://www.cnblogs.com/ssor/archive/2009/06/25/1510826.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值