I have a control inherited from System.Windows.Forms.Control which has the WndProc function overridden to pass the messages to an external DLL. The function looks like
public class GraphicsPanel : Control
{
bool designMode;
EngineWrapper Engine;
public GraphicsPanel()
{
designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
this.SetStyle(ControlStyles.Selectable, true);
this.TabStop = true;
}
public void SetEngine(EngineWrapper Engine)
{
this.Engine = Engine;
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if(designMode) // Tried this option
return;
if (!designMode && Engine != null) // And this option
Engine.ProcessWindowMessage(m.Msg, m.WParam, m.LParam);
}
}
If I have any mention of Engine in this function, it crashes because the external DLL apparently isn't loaded when the designer is displayed. I get the error message "Could not load file or assembly "..." or one of its dependencies.
I certainly should add that this code all works at run-time just not design-time. It's annoying having to comment out the two Engine lines of code whenever I want to use the designer.
Any advice for how to get the designer to work correctly while including this line of code.