473,721 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Componen tModel.Design.E ventBindingServ ice.EventProper tyDescriptor.Se tValue(Object
component, Object value)
at
System.Componen tModel.Design.S erialization.Co deDomSerializer Base.Deserializ eAttachEventSta tement(IDesigne rSerializationM anager
manager, CodeAttachEvent Statement statement)
at
System.Componen tModel.Design.S erialization.Co deDomSerializer Base.Deserializ eStatement(IDes ignerSerializat ionManager
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.Componen tModel.Design.E ventBindingServ ice.EventProper tyDescriptor.Se tValue(Object
component, Object value)
at
System.Componen tModel.Design.S erialization.Co deDomSerializer Base.Deserializ eAttachEventSta tement(IDesigne rSerializationM anager
manager, CodeAttachEvent Statement statement)
at
System.Componen tModel.Design.S erialization.Co deDomSerializer Base.Deserializ eStatement(IDes ignerSerializat ionManager
manager, CodeStatement statement)

Method 'System.Windows .Forms.Form.Set Style' not found.
Hide
at System.RuntimeT ype.InvokeMembe r(String name, BindingFlags bindingFlags,
Binder binder, Object target, Object[] providedArgs, ParameterModifi er[]
modifiers, CultureInfo culture, String[] namedParams)
at
System.Componen tModel.Design.S erialization.Co deDomSerializer Base.Deserializ eExpression(IDe signerSerializa tionManager
manager, String name, CodeExpression expression)
at
System.Componen tModel.Design.S erialization.Co deDomSerializer Base.Deserializ eStatement(IDes ignerSerializat ionManager
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 5827
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

"ThunderMus ic" <No************ *************@N oSpAm.comwrote in message
news:uV******** ******@TK2MSFTN GP04.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.Componen tModel.Design.E ventBindingServ ice.EventProper tyDescriptor.Se tValue(Object
component, Object value)
at
System.Componen tModel.Design.S erialization.Co deDomSerializer Base.Deserializ eAttachEventSta tement(IDesigne rSerializationM anager
manager, CodeAttachEvent Statement statement)
at
System.Componen tModel.Design.S erialization.Co deDomSerializer Base.Deserializ eStatement(IDes ignerSerializat ionManager
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.Componen tModel.Design.E ventBindingServ ice.EventProper tyDescriptor.Se tValue(Object
component, Object value)
at
System.Componen tModel.Design.S erialization.Co deDomSerializer Base.Deserializ eAttachEventSta tement(IDesigne rSerializationM anager
manager, CodeAttachEvent Statement statement)
at
System.Componen tModel.Design.S erialization.Co deDomSerializer Base.Deserializ eStatement(IDes ignerSerializat ionManager
manager, CodeStatement statement)

Method 'System.Windows .Forms.Form.Set Style' not found.
Hide
at System.RuntimeT ype.InvokeMembe r(String name, BindingFlags bindingFlags,
Binder binder, Object target, Object[] providedArgs, ParameterModifi er[]
modifiers, CultureInfo culture, String[] namedParams)
at
System.Componen tModel.Design.S erialization.Co deDomSerializer Base.Deserializ eExpression(IDe signerSerializa tionManager
manager, String name, CodeExpression expression)
at
System.Componen tModel.Design.S erialization.Co deDomSerializer Base.Deserializ eStatement(IDes ignerSerializat ionManager
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.CreatePar ams CreateParams
{
get
{
CreateParams cp = base.CreatePara ms;
if (!this.DesignMo de)
{
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.OSV ersion.Version. Major * 10;
OSVER += Environment.OSV ersion.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
"ThunderMus ic" <No************ *************@N oSpAm.comwrote in message
news:%2******** ********@TK2MSF TNGP03.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

"ThunderMus ic" <No************ *************@N oSpAm.comwrote in message
news:uV******** ******@TK2MSFTN GP04.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.Compone ntModel.Design. EventBindingSer vice.EventPrope rtyDescriptor.S etValue(Object
component, Object value)
at
System.Compone ntModel.Design. Serialization.C odeDomSerialize rBase.Deseriali zeAttachEventSt atement(IDesign erSerialization Manager
manager, CodeAttachEvent Statement statement)
at
System.Compone ntModel.Design. Serialization.C odeDomSerialize rBase.Deseriali zeStatement(IDe signerSerializa tionManager
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.Compone ntModel.Design. EventBindingSer vice.EventPrope rtyDescriptor.S etValue(Object
component, Object value)
at
System.Compone ntModel.Design. Serialization.C odeDomSerialize rBase.Deseriali zeAttachEventSt atement(IDesign erSerialization Manager
manager, CodeAttachEvent Statement statement)
at
System.Compone ntModel.Design. Serialization.C odeDomSerialize rBase.Deseriali zeStatement(IDe signerSerializa tionManager
manager, CodeStatement statement)

Method 'System.Windows .Forms.Form.Set Style' not found.
Hide
at System.RuntimeT ype.InvokeMembe r(String name, BindingFlags
bindingFlags , Binder binder, Object target, Object[] providedArgs,
ParameterModif ier[] modifiers, CultureInfo culture, String[] namedParams)
at
System.Compone ntModel.Design. Serialization.C odeDomSerialize rBase.Deseriali zeExpression(ID esignerSerializ ationManager
manager, String name, CodeExpression expression)
at
System.Compone ntModel.Design. Serialization.C odeDomSerialize rBase.Deseriali zeStatement(IDe signerSerializa tionManager
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.SQUA REBRACKETS.[mdaudi100#ntlwo rld.com]wrote in
message news:%2******** *******@TK2MSFT NGP02.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.CreatePar ams CreateParams
{
get
{
CreateParams cp = base.CreatePara ms;
if (!this.DesignMo de)
{
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.OSV ersion.Version. Major * 10;
OSVER += Environment.OSV ersion.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
"ThunderMus ic" <No************ *************@N oSpAm.comwrote in message
news:%2******** ********@TK2MSF TNGP03.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

"ThunderMusi c" <No************ *************@N oSpAm.comwrote in message
news:uV******* *******@TK2MSFT NGP04.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.Compon entModel.Design .EventBindingSe rvice.EventProp ertyDescriptor. SetValue(Object
component, Object value)
at
System.Compon entModel.Design .Serialization. CodeDomSerializ erBase.Deserial izeAttachEventS tatement(IDesig nerSerializatio nManager
manager, CodeAttachEvent Statement statement)
at
System.Compon entModel.Design .Serialization. CodeDomSerializ erBase.Deserial izeStatement(ID esignerSerializ ationManager
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.Compon entModel.Design .EventBindingSe rvice.EventProp ertyDescriptor. SetValue(Object
component, Object value)
at
System.Compon entModel.Design .Serialization. CodeDomSerializ erBase.Deserial izeAttachEventS tatement(IDesig nerSerializatio nManager
manager, CodeAttachEvent Statement statement)
at
System.Compon entModel.Design .Serialization. CodeDomSerializ erBase.Deserial izeStatement(ID esignerSerializ ationManager
manager, CodeStatement statement)

Method 'System.Windows .Forms.Form.Set Style' not found.
Hide
at System.RuntimeT ype.InvokeMembe r(String name, BindingFlags
bindingFlag s, Binder binder, Object target, Object[] providedArgs,
ParameterModi fier[] modifiers, CultureInfo culture, String[]
namedParams )
at
System.Compon entModel.Design .Serialization. CodeDomSerializ erBase.Deserial izeExpression(I DesignerSeriali zationManager
manager, String name, CodeExpression expression)
at
System.Compon entModel.Design .Serialization. CodeDomSerializ erBase.Deserial izeStatement(ID esignerSerializ ationManager
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

ThunderMusi c




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
2444
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 fine. However, when attempting to assing default values as designtime in the propertygrid, nothing is working on the class object. I know that I am doing it wrong, any ideas what it is? Thanks in advance
10
10046
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 believe that this has to do with unreleased form component events or event handlers. I'm comparatively new to .net and windows forms, in the sense that though I've been using them for over 2 years now, it's been rather sporadic. I work with...
4
3705
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 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...
11
18137
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 ListView columns so it should be doable, thanks
15
6519
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 accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then i added this line "" before my custom control class (i dont know what this line does). Now
0
1968
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 the ini on the client's PC. After the program has ended the control looks in a client side temp folder (specified by the ini file) for an image created by the executed program. If the image is there, then the control moves the file to a public folder...
2
5112
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 = Windows Forms class B = a singleton hosted within A. B is responsible for dynamically loading classes X, Y, and Z.
11
10144
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 seen erratic results. I am aware of one known defect where user classes do not show up in the list of types on the Property/Settings page in the visual designer and I am wondering if I am encountering some other peculiar issue, or if there are...
5
4122
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 to wrap the control in the proper control type - which is also a container. At design time I want to be able to turn this : <my:container> <asp:textbox />
0
8728
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9130
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9059
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6668
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4751
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.