该类型是在未引用的程序集,如何查找原因界定? [英] The type is defined in an assembly that is not referenced, how to find the cause?

查看:217
本文介绍了该类型是在未引用的程序集,如何查找原因界定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个错误消息是常见的,有很多关于这个错误的问题上如此,但没有解决方案已帮助了我这么远,所以我决定要问的问题。差异的大部分类似的问题是我使用APP_ code目录中。

I know the error message is common and there are plenty of questions on SO about this error, but no solutions have helped me so far, so I decided to ask the question. Difference to most of similar questions is me using App_Code directory.

错误消息:

CS0012: The type 'Project.Rights.OperationsProvider' is defined in an
assembly that is not referenced. You must add a reference to assembly
'Project.Rights, version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

源文件:

c:\inetpub\wwwroot\Test\Website\App_Code\Company\Project\BusinessLogic\Manager.cs

以下建议<一href="http://stackoverflow.com/questions/496269/asp-net-page-says-i-need-to-reference-an-assembly-that-does-not-exist">here和<一href="http://stackoverflow.com/questions/284433/strange-error-cs0012-the-type-x-is-defined-in-an-assembly-that-is-not-referen">here,我已删除Project.Rights.dll的所有实例里面的C:\ WINDOWS \ Microsoft.NET /*.* 根据这个,我检查,如果在的.cs文件问题有生成操作设置为编译。他们是这样。 我也双重检查了包含Project.Rights.OperationsProvider式的cs文件部署到APP_ code目录中。

Following suggestions here and here, I have deleted all instances of Project.Rights.dll inside C:\Windows\Microsoft.NET/*.* According to this, I checked if .cs files in question have build action set to "Compile". They do. I have also double checked that the .cs file containing the "Project.Rights.OperationsProvider" type is deployed to App_Code directory.

由于某些原因,应用程序是不是找的APP_ code目录的类型。既然我已经删除Project.Rights.dll的所有实例(据我所知),我不知道哪个组件上的错误消息提。

For some reason, application is not looking for the type in the App_Code directory. Since I've deleted all instances of Project.Rights.dll (that I know of), I don't know which assembly the error message is mentioning.

推荐答案

当你得到这个错误并不总是显而易见的是怎么回事,但因为错误说 - 你缺少一个参考。取code以下线为例:

When you get this error it isn't always obvious what is going on, but as the error says - you are missing a reference. Take the following line of code as an example:

MyObjectType a = new MyObjectType("parameter");

这看起来很简单,你可能已引用MyObjectType正确。但可以说的过载为MyObjectType构造函数对应一个发生,你不已经引用的类型。例如有一个定义为过载:

It looks simple enough and you probably have referenced "MyObjectType" correctly. But lets say one of the overloads for the "MyObjectType" constructor takes a type that you don't have referenced. For example there is an overload defined as:

public MyObjectType(TypeFromOtherAssembly parameter) {
    // ... normal constructor code ...
}

这是至少有一个情况下,你会得到这个错误。所以,看起来对这种类型的图案,其中已引用的类型,但性质或方法参数,它们可能对功能不是所有的类型被称为上的该类型。

That is at least one case where you will get this error. So, look for this type of pattern where you have referenced the type but not all the types of the properties or method parameters that are possible for functions being called on that type.

希望这至少可以让你在正确的方向前进!

Hopefully this at least gets you going in the right direction!

这篇关于该类型是在未引用的程序集,如何查找原因界定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆