C# 编译器说函数未定义,但实际上是
我只需要另一双眼睛...我不认为以下内容有任何问题。事实上,我发誓不久前我就有了这样的东西,而且它很有效。
在我的 Collections.dll 中:
namespace Collections
{
public class CSuperAutoPool
{
public static CSuperAutoPool ActivateByType(Type typeToBeActivated, params object[] activatedArguments)
{
//...
}
}
}
在另一个 DLL 中,我引用了集合 DLL 项目,并在此函数中使用它:
namespace Organization
{
public class CBaseEntity : CSuperAutoPool
{
protected static CBaseEntity Create()
{
//...
CBaseEntity created = (CBaseEntity)CSuperAutoPool.ActivateByType(callingType); //Error here.
//...
}
}
}
错误:'Collections.CSuperAutoPool' 不包含 'ActivateByType' 的定义
我在 CSuperAutoPool 中使用了 ActivateByType,一种不同的功能,并且该功能没有错误。 Collections DLL 编译时没有错误。在 Organization 命名空间存在的同一 DLL 中,以其他方式使用了 CSuperAutoPool 类的各个其他方面,没有编译器错误。
I just need another pair of eyes... I don't see anything wrong with the following. In fact, I swear I had something just like this not long ago, and it worked.
In my Collections.dll:
namespace Collections
{
public class CSuperAutoPool
{
public static CSuperAutoPool ActivateByType(Type typeToBeActivated, params object[] activatedArguments)
{
//...
}
}
}
In another DLL, I have referenced the collections DLL project, and use it in this function:
namespace Organization
{
public class CBaseEntity : CSuperAutoPool
{
protected static CBaseEntity Create()
{
//...
CBaseEntity created = (CBaseEntity)CSuperAutoPool.ActivateByType(callingType); //Error here.
//...
}
}
}
Error: 'Collections.CSuperAutoPool' does not contain a definition for 'ActivateByType'
I have used ActivateByType, within CSuperAutoPool, in a different function, and that one does not have errors. The Collections DLL compiles without errors. In the same DLL where the Organization namespace exists, have used various other aspects of the CSuperAutoPool class in other ways, without compiler errors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的示例中一定缺少某些内容,或者您没有使用您认为正在使用的代码版本,例如,您的项目中可能存在另一个名为
CSuperAutoPool
的类,可能在引用的程序集?以下代码片段编译无错误:
There must be something missing from your example, or you are not using the version of the code that you think you are using, e.g. could it be that there is another class called
CSuperAutoPool
in your project, possibly in a referenced assembly?The following snippets compiles without errors:
找到了! 0xA3 给了我所需的提示:“您没有使用您认为正在使用的代码版本”
当我将集合引用添加到组织项目时,它没有选中要在配置管理器中编译的集合项目。换句话说,除非我手动编译,否则我的 Collections DLL 无法编译。
谢谢,这就是我所说的多一双眼睛的意思。 :-)
Found it! 0xA3 gave me the hint I needed with: "you are not using the version of the code that you think you are using"
When I added the Collections reference to the Organization project, it did not checkmark the Collections project to compile in the Configurations Manager. In other words, my Collections DLL was not compiling unless I did it by hand.
Thank you, that's what I meant by an extra set of eyes. :-)