By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 1,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

Custom Form working at runtime but cannot be loaded in designer

P: n/a
Hi,
I have a custom form that works fine when I debug it or run it in release
mode but cannot be loaded in the designer... Actually, it can be loaded in
the designer when no control is on it, but the resizing tool (in the
designer) is offset both horizontally and vertically and when I put a
control on it, as soon as I save, the designer throws an exception (but
cannot be reproduced everytime) and the form cannot be loaded anymore unless
I remove all the controls from it... but the major problem is the offset of
the designer... also, I'm unable to move the newly added controls on my
form... I can resize them when I add them and after that cannot even select
them... this behavior happens when I want to use the custom form (inherit
forms of my projects from this form)...

When I want to see the form in the designer (the CustomForm itself inherited
from system.windows.forms.form) I receive and exception too (here it is)

Events cannot be set on the object passed to the event binding service
because a site associated with the object could not be located.
Hide
at
System.ComponentModel.Design.EventBindingService.E ventPropertyDescriptor.SetValue(Object
component, Object value)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeAttachEventStatement(IDe signerSerializationManager
manager, CodeAttachEventStatement statement)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeStatement(IDesignerSeria lizationManager
manager, CodeStatement statement)

Events cannot be set on the object passed to the event binding service
because a site associated with the object could not be located.
Hide
at
System.ComponentModel.Design.EventBindingService.E ventPropertyDescriptor.SetValue(Object
component, Object value)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeAttachEventStatement(IDe signerSerializationManager
manager, CodeAttachEventStatement statement)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeStatement(IDesignerSeria lizationManager
manager, CodeStatement statement)

Method 'System.Windows.Forms.Form.SetStyle' not found.
Hide
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags,
Binder binder, Object target, Object[] providedArgs, ParameterModifier[]
modifiers, CultureInfo culture, String[] namedParams)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeExpression(IDesignerSeri alizationManager
manager, String name, CodeExpression expression)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeStatement(IDesignerSeria lizationManager
manager, CodeStatement statement)
Does anybody know the solution to this kind of behavior? btw, it may be
relevant to say I'm using a custom message filter (IMessageFilter)

Thanks

ThunderMusic
Nov 22 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
ok... great I solved most of my problems... the only thing remaining is
the fact that the form appears offset with the sizing anchors in the
designer when I inherit from it.

So let's say I have my CustomForm, then I create a form like this "public
class MyForm : CustomForm"... Everytime I want to load MyForm in the
designer, the anchors are offset... the form itself is in the right place,
but the anchors are offset low and right and everything I place on the form
is located at 0,0 and cannot be moved in the designer (cannot even be
selected again after I select anything else at creation)... I can move them
into the MyForm.designer.cs tought, and it works fine, but it's not the
"normal" behavior of things... does anybody can point me to some possible
causes for this problem?

thanks

ThunderMusic

"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:uV**************@TK2MSFTNGP04.phx.gbl...
Hi,
I have a custom form that works fine when I debug it or run it in release
mode but cannot be loaded in the designer... Actually, it can be loaded
in the designer when no control is on it, but the resizing tool (in the
designer) is offset both horizontally and vertically and when I put a
control on it, as soon as I save, the designer throws an exception (but
cannot be reproduced everytime) and the form cannot be loaded anymore
unless I remove all the controls from it... but the major problem is the
offset of the designer... also, I'm unable to move the newly added
controls on my form... I can resize them when I add them and after that
cannot even select them... this behavior happens when I want to use the
custom form (inherit forms of my projects from this form)...

When I want to see the form in the designer (the CustomForm itself
inherited from system.windows.forms.form) I receive and exception too
(here it is)

Events cannot be set on the object passed to the event binding service
because a site associated with the object could not be located.
Hide
at
System.ComponentModel.Design.EventBindingService.E ventPropertyDescriptor.SetValue(Object
component, Object value)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeAttachEventStatement(IDe signerSerializationManager
manager, CodeAttachEventStatement statement)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeStatement(IDesignerSeria lizationManager
manager, CodeStatement statement)

Events cannot be set on the object passed to the event binding service
because a site associated with the object could not be located.
Hide
at
System.ComponentModel.Design.EventBindingService.E ventPropertyDescriptor.SetValue(Object
component, Object value)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeAttachEventStatement(IDe signerSerializationManager
manager, CodeAttachEventStatement statement)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeStatement(IDesignerSeria lizationManager
manager, CodeStatement statement)

Method 'System.Windows.Forms.Form.SetStyle' not found.
Hide
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags,
Binder binder, Object target, Object[] providedArgs, ParameterModifier[]
modifiers, CultureInfo culture, String[] namedParams)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeExpression(IDesignerSeri alizationManager
manager, String name, CodeExpression expression)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeStatement(IDesignerSeria lizationManager
manager, CodeStatement statement)
Does anybody know the solution to this kind of behavior? btw, it may be
relevant to say I'm using a custom message filter (IMessageFilter)

Thanks

ThunderMusic


Nov 23 '06 #2

P: n/a
Sorry for the slow response, but I've been busy.

Because you are using the method on my site, most users may not even have
seen the error without further info. I happen to know what you're doing
because of a previous thread.

When Inheriting the shapedform class you need to make sure that the
CreateParams is not applied in DesignTime, so the CreateParams method should
be modified as below:

protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
if (!this.DesignMode)
{
const int WS_CLIPCHILDREN = 0x2000000;
const int WS_MINIMIZEBOX = 0x20000;
//const int WS_MAXIMIZEBOX = 0x10000;
const int WS_SYSMENU = 0x80000;

const int CS_DBLCLKS = 0x8;
const int CS_DROPSHADOW = 0x20000;

int ClassFlags = CS_DBLCLKS;
int OSVER = Environment.OSVersion.Version.Major * 10;
OSVER += Environment.OSVersion.Version.Minor;
if (OSVER >= 51) ClassFlags = CS_DBLCLKS | CS_DROPSHADOW;

cp.Style = WS_CLIPCHILDREN | WS_MINIMIZEBOX | WS_SYSMENU;

cp.ClassStyle = ClassFlags;
}
return cp;
}
}
--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
ok... great I solved most of my problems... the only thing remaining is
the fact that the form appears offset with the sizing anchors in the
designer when I inherit from it.

So let's say I have my CustomForm, then I create a form like this "public
class MyForm : CustomForm"... Everytime I want to load MyForm in the
designer, the anchors are offset... the form itself is in the right
place, but the anchors are offset low and right and everything I place on
the form is located at 0,0 and cannot be moved in the designer (cannot
even be selected again after I select anything else at creation)... I can
move them into the MyForm.designer.cs tought, and it works fine, but it's
not the "normal" behavior of things... does anybody can point me to some
possible causes for this problem?

thanks

ThunderMusic

"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:uV**************@TK2MSFTNGP04.phx.gbl...
>Hi,
I have a custom form that works fine when I debug it or run it in release
mode but cannot be loaded in the designer... Actually, it can be loaded
in the designer when no control is on it, but the resizing tool (in the
designer) is offset both horizontally and vertically and when I put a
control on it, as soon as I save, the designer throws an exception (but
cannot be reproduced everytime) and the form cannot be loaded anymore
unless I remove all the controls from it... but the major problem is the
offset of the designer... also, I'm unable to move the newly added
controls on my form... I can resize them when I add them and after that
cannot even select them... this behavior happens when I want to use the
custom form (inherit forms of my projects from this form)...

When I want to see the form in the designer (the CustomForm itself
inherited from system.windows.forms.form) I receive and exception too
(here it is)

Events cannot be set on the object passed to the event binding service
because a site associated with the object could not be located.
Hide
at
System.ComponentModel.Design.EventBindingService. EventPropertyDescriptor.SetValue(Object
component, Object value)
at
System.ComponentModel.Design.Serialization.CodeDo mSerializerBase.DeserializeAttachEventStatement(ID esignerSerializationManager
manager, CodeAttachEventStatement statement)
at
System.ComponentModel.Design.Serialization.CodeDo mSerializerBase.DeserializeStatement(IDesignerSeri alizationManager
manager, CodeStatement statement)

Events cannot be set on the object passed to the event binding service
because a site associated with the object could not be located.
Hide
at
System.ComponentModel.Design.EventBindingService. EventPropertyDescriptor.SetValue(Object
component, Object value)
at
System.ComponentModel.Design.Serialization.CodeDo mSerializerBase.DeserializeAttachEventStatement(ID esignerSerializationManager
manager, CodeAttachEventStatement statement)
at
System.ComponentModel.Design.Serialization.CodeDo mSerializerBase.DeserializeStatement(IDesignerSeri alizationManager
manager, CodeStatement statement)

Method 'System.Windows.Forms.Form.SetStyle' not found.
Hide
at System.RuntimeType.InvokeMember(String name, BindingFlags
bindingFlags, Binder binder, Object target, Object[] providedArgs,
ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at
System.ComponentModel.Design.Serialization.CodeDo mSerializerBase.DeserializeExpression(IDesignerSer ializationManager
manager, String name, CodeExpression expression)
at
System.ComponentModel.Design.Serialization.CodeDo mSerializerBase.DeserializeStatement(IDesignerSeri alizationManager
manager, CodeStatement statement)
Does anybody know the solution to this kind of behavior? btw, it may be
relevant to say I'm using a custom message filter (IMessageFilter)

Thanks

ThunderMusic



Nov 23 '06 #3

P: n/a
Great!!! everything is solved now... thanks a bunch... ;) I modified your
solution a bit to remove the border at design time because, anyways, it's
not useful to show it as it will not be visible at runtime... and it does
not cause any problem to remove it at design time (no one I can see right
now, if you think of one, let me know)

Thanks a lot again!!

ThunderMusic
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]wrote in
message news:%2***************@TK2MSFTNGP02.phx.gbl...
Sorry for the slow response, but I've been busy.

Because you are using the method on my site, most users may not even have
seen the error without further info. I happen to know what you're doing
because of a previous thread.

When Inheriting the shapedform class you need to make sure that the
CreateParams is not applied in DesignTime, so the CreateParams method
should be modified as below:

protected override System.Windows.Forms.CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
if (!this.DesignMode)
{
const int WS_CLIPCHILDREN = 0x2000000;
const int WS_MINIMIZEBOX = 0x20000;
//const int WS_MAXIMIZEBOX = 0x10000;
const int WS_SYSMENU = 0x80000;

const int CS_DBLCLKS = 0x8;
const int CS_DROPSHADOW = 0x20000;

int ClassFlags = CS_DBLCLKS;
int OSVER = Environment.OSVersion.Version.Major * 10;
OSVER += Environment.OSVersion.Version.Minor;
if (OSVER >= 51) ClassFlags = CS_DBLCLKS | CS_DROPSHADOW;

cp.Style = WS_CLIPCHILDREN | WS_MINIMIZEBOX | WS_SYSMENU;

cp.ClassStyle = ClassFlags;
}
return cp;
}
}
--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>ok... great I solved most of my problems... the only thing remaining is
the fact that the form appears offset with the sizing anchors in the
designer when I inherit from it.

So let's say I have my CustomForm, then I create a form like this "public
class MyForm : CustomForm"... Everytime I want to load MyForm in the
designer, the anchors are offset... the form itself is in the right
place, but the anchors are offset low and right and everything I place on
the form is located at 0,0 and cannot be moved in the designer (cannot
even be selected again after I select anything else at creation)... I can
move them into the MyForm.designer.cs tought, and it works fine, but it's
not the "normal" behavior of things... does anybody can point me to some
possible causes for this problem?

thanks

ThunderMusic

"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:uV**************@TK2MSFTNGP04.phx.gbl...
>>Hi,
I have a custom form that works fine when I debug it or run it in
release mode but cannot be loaded in the designer... Actually, it can
be loaded in the designer when no control is on it, but the resizing
tool (in the designer) is offset both horizontally and vertically and
when I put a control on it, as soon as I save, the designer throws an
exception (but cannot be reproduced everytime) and the form cannot be
loaded anymore unless I remove all the controls from it... but the
major problem is the offset of the designer... also, I'm unable to move
the newly added controls on my form... I can resize them when I add them
and after that cannot even select them... this behavior happens when I
want to use the custom form (inherit forms of my projects from this
form)...

When I want to see the form in the designer (the CustomForm itself
inherited from system.windows.forms.form) I receive and exception too
(here it is)

Events cannot be set on the object passed to the event binding service
because a site associated with the object could not be located.
Hide
at
System.ComponentModel.Design.EventBindingService .EventPropertyDescriptor.SetValue(Object
component, Object value)
at
System.ComponentModel.Design.Serialization.CodeD omSerializerBase.DeserializeAttachEventStatement(I DesignerSerializationManager
manager, CodeAttachEventStatement statement)
at
System.ComponentModel.Design.Serialization.CodeD omSerializerBase.DeserializeStatement(IDesignerSer ializationManager
manager, CodeStatement statement)

Events cannot be set on the object passed to the event binding service
because a site associated with the object could not be located.
Hide
at
System.ComponentModel.Design.EventBindingService .EventPropertyDescriptor.SetValue(Object
component, Object value)
at
System.ComponentModel.Design.Serialization.CodeD omSerializerBase.DeserializeAttachEventStatement(I DesignerSerializationManager
manager, CodeAttachEventStatement statement)
at
System.ComponentModel.Design.Serialization.CodeD omSerializerBase.DeserializeStatement(IDesignerSer ializationManager
manager, CodeStatement statement)

Method 'System.Windows.Forms.Form.SetStyle' not found.
Hide
at System.RuntimeType.InvokeMember(String name, BindingFlags
bindingFlags, Binder binder, Object target, Object[] providedArgs,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParams)
at
System.ComponentModel.Design.Serialization.CodeD omSerializerBase.DeserializeExpression(IDesignerSe rializationManager
manager, String name, CodeExpression expression)
at
System.ComponentModel.Design.Serialization.CodeD omSerializerBase.DeserializeStatement(IDesignerSer ializationManager
manager, CodeStatement statement)
Does anybody know the solution to this kind of behavior? btw, it may be
relevant to say I'm using a custom message filter (IMessageFilter)

Thanks

ThunderMusic




Nov 23 '06 #4

P: n/a
hi!!!

what did you do to get rid of the strange designtime error ?
i got the same problem after upgrading my project from .net 1.1 to 2.0.
all forms that uses my custom usercontrol get this message.
Feb 9 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.