我有一个非常成熟的应用程序。它包含一个继承层次结构,以促进代码重用,并且几天前一直运行良好。它在现实世界中完美运行,但我目前无法设计任何从其中一个基本形式继承的形式。
现在,每次我尝试设计一个继承自MpvViewBase的表单时,都会收到以下错误消息:
方法' CloseView'在类型' CommonForms.MvpViewBase'来自汇编' CommonForms,Version = 1.0.6377.15105,Culture = neutral,PublicKeyToken = null'没有实施。
首先,它 有一个实现,或者代码不能构建它完美的。
其次,显示的版本号不是适用于dll的版本号。
第三,表单是该dll的组成部分,因此不需要外部引用它。
我尝试过的事情:
这些都没有任何区别。我不明白为什么会发生这种情况,因为自2012年以来没有对相关级别进行任何更改。但是,这是一个严重的问题,因为我无法设计从MpvViewBase继承的任何表单 - 而且几乎任何形式的解决方案都是而不是从它继承的消息对话框!
任何人都有任何关于我可能会在下一步找到解决此问题的建议吗?
修改
根据要求,下面是基类和第一个继承类的代码。 MvpViewBase在Designer,ControllableViewBase中打开,从中继承的任何表单都无法打开:
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
}
接口定义代码中的事件和方法,但如果需要,我可以发布它们......
感谢您寻找并提供任何帮助。
修改2
这是来自错误的调用堆栈,以防它给任何人提供任何线索:
此错误的实例(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)
答案 0 :(得分:0)
我发布这个答案是为了完整性,以防它对其他人有帮助,因为它对我有用,但我不知道为什么......
我创建了一个测试解决方案并将有问题的文件单独放入其中,并且我注释掉了所有未从框架中发出的代码。那时我能够点燃设计师。
接下来,我一次取消注释所有代码,它仍然有用。我将文件复制回原始解决方案,但它仍然无法正常工作。
下一阶段是从测试解决方案复制项目文件,此时DID工作,但当然项目中的所有其他文件不再是项目的一部分。为了找到原因,我一次添加一个文件,每次检查设计器在添加文件后仍然有效。
我必须处理一些轻微的连锁效应,但基本上我现在有一个完全有效的解决方案,其形式在设计师中一如既往地打开。
这是否纯属巧合(例如,MS可能在此期间已经完成了后台软件修复),或者它是否真的是错误的项目文件我无法说。但是,如果其他人遇到类似的问题并且在我的情况下,StackOverflow和Google上的其他解决方案都没有起作用,那么可能值得遵循相同的模式来看看它是否有帮助......