RegAsm: Method 'LoadContent' in type 'MyAlgorithms.MyAlgorithm' from assembly 'A' does not have an implementation

StackOverflow https://stackoverflow.com/questions/4606246

Question

I have the following types(see code part below). It is compiled but RegAsm gives the following error: " Method 'LoadContent' in type 'MyAlgorithms.MyAlgorithm' from assembly 'A' does not have an implementation. "

Has any idea why? If I would not implemented LoadContent() method it would not be compiled.

I saw a nearly same question, here: TypeLoadException says 'no implementation', but it is implemented but it did not help, because:

A, B and C projects are in the same solution, and the build order is C, B and A.

"Post-build event command line" of all projects contains the next lines:

"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)

So I think project A refers to the right assemblies.

And why solves the problem if I added to MyAlgorithmBase class the next:

protected override void LoadContent(PersistenceReader reader) { }

Thanks!

KAte

// 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)
  {
  //....
  }
 }
}
Was it helpful?

Solution

The compiler verifies this. Which almost surely means that at runtime, when Regasm.exe loads the assembly, it doesn't load the assembly you think it does. There's plenty of opportunity for this since you use the GAC. Which can produce an old version of a dependent assembly, based on an [AssemblyVersion] number in the reference assembly.

Troubleshoot this with Fuslogvw.exe, log all the binds. It shows you where every assembly came from.

Stay out of this kind of trouble by not putting your assemblies in the GAC. It is a deployment detail and not appropriate on your dev machine where assembly versions can rapidly change, especially when you let the build system automatically increment them. You do so by using the /codebase option for Regasm.exe

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top