【发布时间】:2011-01-06 00:45:53
【问题描述】:
我有以下类型(见下面的代码部分)。它已编译,但 RegAsm 给出以下错误:“方法 'LoadContent' in type 'MyAlgorithms.MyAlgorithm' from assembly 'A' does not have an implementation。”
知道为什么吗?如果我不实现 LoadContent() 方法,它将不会被编译。
我在这里看到了一个几乎相同的问题: TypeLoadException says 'no implementation', but it is implemented 但它没有帮助,因为:
A、B、C项目在同一个解决方案中,构建顺序为C、B、A。
所有项目的“构建后事件命令行”包含下一行:
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe" /u $(TargetPath)
"C:\WINDOWS\Microsoft. NET\Framework\v2.0.50727\RegAsm.exe" $(TargetPath)
"c:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe" /u $(TargetName)
"c:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe" /if $(TargetPath)
所以我认为项目 A 指的是正确的程序集。
如果我将下一个添加到 MyAlgorithmBase 类中,为什么会解决问题:
protected override void LoadContent(PersistenceReader reader) { }
谢谢!
凯特
// C.dll from project C
namespace Microsoft.SqlServer.DataMining.PluginAlgorithms
{
public abstract class AlgorithmBase : IDisposable
{
//....
protected abstract void LoadContent(PersistenceReader reader);
}
}
//in B.dll from project B, refers C.dll
namespace AlgorithmCommons
{
public abstract class MyAlgorithmBase : AlgorithmBase
{
//....
// Why solves the problem if the next line is commented out?
// protected override void LoadContent(PersistenceReader reader) { }
}
}
//in A.dll from project A, refers B.dll and C.dll
namespace MyAlgorithms
{
public class MyAlgorithm : MyAlgorithmBase
{
protected override void LoadContent(PersistenceReader reader)
{
//....
}
}
}
【问题讨论】:
标签: com abstract-class regasm typeloadexception