Reputation: 1903
I must be overlooking something simple. I'm trying to update a class that once used to compile. I'm mostly swapping out similar classes under different namespaces for new code, cleaning up so to speak.
I have one method, TakeAction, that isn't overriding for me. Parent (abstract) class:
namespace MyNamespace.StandardNoteReceiverService
{
public abstract class NoteReceiverHandler : BaseIntegrationService
{
private Vendor.Sys.Services.ReceiveNoteData _ReceiveNoteData;
public NoteReceiverHandler() {}
public NoteReceiverHandler(Vendor.Sys.Services.ReceiveNoteData receiveNoteData)
{
this._ReceiveNoteData = receiveNoteData;
}
public abstract Vendor.Sys.Services.ReceiveNoteResponse TakeAction(Vendor.Sys.Services.ReceiveNoteData receiveNoteData);
}
}
Implementation of the abstract class:
public class Sys2Handler : NoteReceiverHandler
{
public override Vendor.Sys.Services.ReceiveNoteResponse TakeAction(Vendor.Sys.Services.ReceiveNoteData receiveNoteData)
{
return new Vendor.Sys.Services.ReceiveNoteResponse();
}
Am I just overlooking something? This happens even when I use "Quick Actions and Refactorings" to generate the abstract class.
Upvotes: 3
Views: 473
Reputation: 14577
This can possibly happen if your assemblies are targeting different .net Framework versions. I'd double check project settings for each assembly.
Upvotes: 1
Reputation: 3269
The following code providing all classes have the same public accessibility compiles perfectly when in single or multiple assemblies.
namespace StandardNoteReceiverService
{
public abstract class NoteReceiverHandler : BaseIntegrationService
{
private Vendor.Sys.Services.ReceiveNoteData _ReceiveNoteData;
public NoteReceiverHandler() { }
public NoteReceiverHandler(Vendor.Sys.Services.ReceiveNoteData receiveNoteData)
{
this._ReceiveNoteData = receiveNoteData;
}
public abstract Vendor.Sys.Services.ReceiveNoteResponse TakeAction(Vendor.Sys.Services.ReceiveNoteData receiveNoteData);
}
public class Sys2Handler : NoteReceiverHandler
{
public override Services.ReceiveNoteResponse TakeAction(Services.ReceiveNoteData receiveNoteData)
{
throw new NotImplementedException();
}
}
}
The only problems which may prevent compilation are different accessibility modifiers or different/conflicting type identity which by .NET is defined as:
Type name, Assembly Name, Assembly Version, Assembly Public Key Signature
Make sure all dependency tree is correct, accessibility is the same and try to recompile. Satisfying the first condition could be a challenge for large projects so perhaps you should use a dependency tree walker to check that all dependencies are correct.
Keep in mind that proper versioning may save you from many similar errors particularly in large code bases.
Upvotes: 1