473,383 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Custom Form working at runtime but cannot be loaded in designer

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
4 5784
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just...
10
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to...
4
by: ThunderMusic | last post by:
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...
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
0
by: ChopStickr | last post by:
I have a custom control that is embedded (using the object tag) in an html document. The control takes a path to a local client ini file. Reads the file. Executes the program specified in...
2
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application =...
11
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have worked with application settings in VS2005 and C# for awhile, but usually with standard types. I have been trying to store a custom container/class/type in an application setting and I have...
5
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.