I have an application which is quite mature. It contains an inheritance hierarchy to promote code re-use, and has worked perfectly for years until a couple of days ago. It works perfectly in the real world, but I am currently unable to design any form that inherits from one of the base forms.
Now, every time I try to design a form that inherits from MpvViewBase I get this error message:
Method 'CloseView' in type 'CommonForms.MvpViewBase' from assembly 'CommonForms, Version=1.0.6377.15105, Culture=neutral, PublicKeyToken=null' does not have an implementation.
Firstly, it does have an implementation or the code would not build which it does perfectly.
Secondly, the version number displayed is not the version number that applies to the dll.
Thirdly, the form is a component part of that dll so no external reference to it is required.
Things I have tried:
- Clean and rebuild
- Search for every CommonForms.dll on the computer and delete them
- Delete the component model cache
- Copy the minimum to a new solution
None of these have made any difference. I do not understand why this has occurred, since no change at the relevant level has been applied since 2012. However, it is a serious problem since I cannot design ANY forms that inherit from MpvViewBase - and almost any form in the solution that is more than a message dialog inherits from it!
Anybody got any suggestions as to where I might look next to resolve this issue?
Edit
As requested, below is the code for the base class and the first inheriting class. MvpViewBase opens in the Designer, ControllableViewBase and any form inherited from it fails to open:
MvpViewBase
public partial class MvpViewBase : MvpFormBase, IView
{
#region Event Keys
public EventKey<CancelEventArgs> CompleteRequested { get; private set; }
public EventKey GenericChangeNotified{ get; private set; }
public EventKey ShowHelpRequested{ get; private set; }
#endregion
#region Private Instance Members
#endregion
#region Protected Instance Memebers
protected Size InitialSize;
#endregion
#region Constructors
public MvpViewBase()
{
InitializeComponent();
if (AppCommon.RunningFromVisualStudioDesigner)
{
return;
}
InitialiseLocal();
}
#endregion
#region Form Events
protected override void OnClosing(CancelEventArgs e)
{
var args = new CancelEventArgs();
CompleteRequested.Raise(this, args);
e.Cancel = args.Cancel;
base.OnClosing(e);
}
private void MvpViewBaseLoad(object sender, EventArgs e)
{
FormControl.SetCharacterCase(this, (CharacterCasing) CompanySettings.Instance.CharacterCase);
MinimumSize = InitialSize;
}
#endregion
#region Methods
///<summary>
/// Closes the form
///</summary>
public void CloseView()
{
CloseView(MessageResult.None);
}
public void CloseView(MessageResult result)
{
if (InvokeRequired)
{
Invoke((MethodInvoker)(() => CloseView(result)));
return;
}
if (result > MessageResult.None)
{
DialogResult = (DialogResult) result;
}
Close();
}
///<summary>
/// Displays a File Open dialog
///</summary>
///<param name="config">A FileOpenConfiguration object</param>
///<returns>A RequestReponse (string[]) object containing the result</returns>
public DataRequestResponse<string[]> GetOpenFileNames(FileOpenConfiguration config)
{
return FormManager.GetOpenFileNames(config);
}
///<summary>
/// Displays a File Save dialog
///</summary>
///<param name="config">A FileSaveConfiguration object</param>
///<returns>A RequestReponse (string) object containing the result</returns>
public DataRequestResponse<string> GetSaveFileName(FileSaveConfiguration config)
{
return FormManager.GetSaveFileName(config);
}
private void InitialiseLocal()
{
InitialiseEvents();
}
protected virtual void InitialiseEvents()
{
CompleteRequested = new EventKey<CancelEventArgs>(Events);
GenericChangeNotified = new EventKey(Events);
ShowHelpRequested = new EventKey(Events);
}
///<summary>
/// Sets the text in the dialog title bar
///</summary>
///<param name="caption">A string representing the caption text to display</param>
public void SetCaption(string caption)
{
if (IsDisposed)
{
return;
}
if (InvokeRequired)
{
MethodInvoker del = () => SetCaption(caption);
Invoke(del);
return;
}
Text = caption;
}
#endregion
}
ControllableViewBase:
public partial class ControllableViewBase : MvpViewBase, IControllableView
{
#region Event Keys
public EventKey CloseRequested { get; private set; }
public EventKey InitialiseCompleteNotified { get; private set; }
public EventKey OkRequested { get; private set; }
public EventKey RevertRequested { get; private set; }
public EventKey SaveRequested { get; private set; }
#endregion
#region Properties
public bool CloseOptionEnabled
{
get { return closeButton.Enabled; }
set { closeButton.Enabled = value; }
}
public bool HelpOptionEnabled
{
get { return helpButton.Enabled; }
set { helpButton.Enabled = value; }
}
public bool OkOptionEnabled
{
get { return okButton.Enabled; }
set { okButton.Enabled = value; }
}
public bool RevertOptionEnabled
{
get { return revertButton.Enabled; }
set { revertButton.Enabled = value; }
}
public bool SaveOptionEnabled
{
get { return saveButton.Enabled; }
set { saveButton.Enabled = value; }
}
#endregion
#region Constructors
///<summary>
/// The Form Constructor
///</summary>
public ControllableViewBase()
{
InitializeComponent();
if (AppCommon.RunningFromVisualStudioDesigner)
{
return;
}
Initialise();
}
#endregion
#region Methods
private void ControllableViewLoad()
{
SetButtonLocations();
}
private void HookEvents()
{
Load += (sender, args) => ControllableViewLoad();
closeButton.Click += (sender, e) => CloseRequested.Raise(this);
helpButton.Click += (sender, e) => ShowHelpRequested.Raise(this);
okButton.Click += (sender, e) => OkRequested.Raise(this);
revertButton.Click += (sender, e) => RevertRequested.Raise(this);
saveButton.Click += (sender, e) => SaveRequested.Raise(this);
}
protected void Initialise()
{
InitialiseLocalEvents();
HookEvents();
}
private void InitialiseLocalEvents()
{
CloseRequested = new EventKey(Events);
InitialiseCompleteNotified = new EventKey(Events);
OkRequested = new EventKey(Events);
RevertRequested = new EventKey(Events);
SaveRequested = new EventKey(Events);
}
protected virtual void SetButtonLocations()
{
int buttonCount = footerPanel.Controls.OfType<Button>().Count();
const int buttonWidth = 75;
const int gap = 6;
int totalWidth = buttonCount * buttonWidth + (gap * buttonCount - 1);
int left = footerPanel.Width - totalWidth - 6;
okButton.Left = left;
left += buttonWidth + gap;
saveButton.Left = left;
left += buttonWidth + gap;
closeButton.Left = left;
left += buttonWidth + gap;
revertButton.Left = left;
left += buttonWidth + gap;
helpButton.Left = left;
}
#endregion
}
The interfaces define the events and methods in the code, but I can post them if required...
Thanks for looking and for any help offered.
Edit 2
Here is the call stack from the error, in case it helps give anyone any clues:
Instances of this error (1)
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Boolean allowPrivate, Assembly& assembly, String description)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, String description)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchProjectEntries(AssemblyName assemblyName, String typeName, Boolean ignoreTypeCase, Assembly& assembly)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchEntries(AssemblyName assemblyName, String typeName, Boolean ignoreCase, Assembly& assembly, ReferenceType refType)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType refType)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name)
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.GetType(String typeName)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)