Control problem HELP!!

T

Tomer

Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type cannot be
converted to target type" in the task list.
Also when I change the property value to something other then the default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check that in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 
P

Peter Foot [MVP]

Have you assigned a default value attribute to your designer, also what
about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter
 
T

Tomer

I'll try putting a default value, although I think I get some problems with
it.
I will also try the second option you've suggested.

I'm not using the ContentAlignment , but rather an enum of my own.
First I've defined it inside the control class, but this made me some
problems, so I've moved it to an external class.
But then this problem started to happen.

By the way thanks for help.

Tomer.


Peter Foot said:
Have you assigned a default value attribute to your designer, also what
about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Tomer said:
Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type cannot be
converted to target type" in the task list.
Also when I change the property value to something other then the
default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check that in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 
T

Tomer

I've added the line and it solved the problem, now the enum value is stored
currectly (THANKS!!)

but I still get that error in the task list.

Tomer.


Peter Foot said:
Have you assigned a default value attribute to your designer, also what
about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Tomer said:
Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type cannot be
converted to target type" in the task list.
Also when I change the property value to something other then the
default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check that in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 
T

Tomer

Well it didn't work after all. Probably because of this error.

Any other suggestions?

Tomer.


Peter Foot said:
Have you assigned a default value attribute to your designer, also what
about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Tomer said:
Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type cannot be
converted to target type" in the task list.
Also when I change the property value to something other then the
default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check that in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 
P

Peter Foot [MVP]

The name doesn't clash with an existing enumeration? it is publically
declared in both your runtime and designtime assemblies?

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Tomer said:
I've added the line and it solved the problem, now the enum value is
stored currectly (THANKS!!)

but I still get that error in the task list.

Tomer.


Peter Foot said:
Have you assigned a default value attribute to your designer, also what
about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Tomer said:
Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type cannot be
converted to target type" in the task list.
Also when I change the property value to something other then the
default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check that
in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 
A

Alex Feinman [MVP]

How did you define your enum?

--
Alex Feinman
---
Visit http://www.opennetcf.org
Tomer said:
Well it didn't work after all. Probably because of this error.

Any other suggestions?

Tomer.


Peter Foot said:
Have you assigned a default value attribute to your designer, also what
about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Tomer said:
Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type cannot be
converted to target type" in the task list.
Also when I change the property value to something other then the
default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check that
in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 
T

Tomer

I've defined it as follows:

/// <summary>

/// Specifies valid values for text alignment

/// </summary>

public enum LabelTextAlignment : byte

{

/// <summary>

/// </summary>

Left = 0,

/// <summary>

/// </summary>

Center = 1,

/// <summary>

/// </summary>

Right = 2

}



Tomer.

Alex Feinman said:
How did you define your enum?

--
Alex Feinman
---
Visit http://www.opennetcf.org
Tomer said:
Well it didn't work after all. Probably because of this error.

Any other suggestions?

Tomer.


Peter Foot said:
Have you assigned a default value attribute to your designer, also what
about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type cannot be
converted to target type" in the task list.
Also when I change the property value to something other then the
default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check that
in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 
T

Tomer

No its a new name. I've used LabelTextAlignment, and its publically declared
for both runtime and design time.
By the way I've no runtime dll, I'm compiling the controls with the main
executable.

Does the version numbering should cause trouble?

Thanks for the help!

Tomer.

Peter Foot said:
The name doesn't clash with an existing enumeration? it is publically
declared in both your runtime and designtime assemblies?

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Tomer said:
I've added the line and it solved the problem, now the enum value is
stored currectly (THANKS!!)

but I still get that error in the task list.

Tomer.


Peter Foot said:
Have you assigned a default value attribute to your designer, also what
about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type cannot be
converted to target type" in the task list.
Also when I change the property value to something other then the
default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check that
in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 
P

Peter Foot [MVP]

I would recommend that you place the control and required enumeration in a
dll which you reference from your exe. That way you can keep the runtime and
designer dlls in sync - yes the version must match exactly - your designer
assembly includes a RuntimeAssemblyAttribute which determines the dll which
will provide the functionality for runtime, the signature of this must match
exactly with your runtime dll. Since an exe doesn't expose types for
external consumption you current setup is unsupported.

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Tomer said:
No its a new name. I've used LabelTextAlignment, and its publically
declared for both runtime and design time.
By the way I've no runtime dll, I'm compiling the controls with the main
executable.

Does the version numbering should cause trouble?

Thanks for the help!

Tomer.

Peter Foot said:
The name doesn't clash with an existing enumeration? it is publically
declared in both your runtime and designtime assemblies?

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Tomer said:
I've added the line and it solved the problem, now the enum value is
stored currectly (THANKS!!)

but I still get that error in the task list.

Tomer.


Have you assigned a default value attribute to your designer, also what
about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type cannot
be
converted to target type" in the task list.
Also when I change the property value to something other then the
default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check that
in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 
A

Alex Feinman [MVP]

If what Peter suggested does not help by itself, try also changing the enum
not to derive from byte. Could be the designer does not like it. Also, there
is no or little point to using byte-based enum. All CPU operations and
registers are 32-bit, and the structure members are 32-bit aligned as well.
So unless you need a very large array of these values (doesn't look like
it), you are not gaining anything


--
Alex Feinman
---
Visit http://www.opennetcf.org
Tomer said:
I've defined it as follows:

/// <summary>

/// Specifies valid values for text alignment

/// </summary>

public enum LabelTextAlignment : byte

{

/// <summary>

/// </summary>

Left = 0,

/// <summary>

/// </summary>

Center = 1,

/// <summary>

/// </summary>

Right = 2

}



Tomer.

Alex Feinman said:
How did you define your enum?

--
Alex Feinman
---
Visit http://www.opennetcf.org
Tomer said:
Well it didn't work after all. Probably because of this error.

Any other suggestions?

Tomer.


Have you assigned a default value attribute to your designer, also what
about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type cannot
be
converted to target type" in the task list.
Also when I change the property value to something other then the
default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check that
in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 
T

Tomer

Thanks, I will follow these tips and keep you posted.

Alex Feinman said:
If what Peter suggested does not help by itself, try also changing the
enum not to derive from byte. Could be the designer does not like it.
Also, there is no or little point to using byte-based enum. All CPU
operations and registers are 32-bit, and the structure members are 32-bit
aligned as well. So unless you need a very large array of these values
(doesn't look like it), you are not gaining anything


--
Alex Feinman
---
Visit http://www.opennetcf.org
Tomer said:
I've defined it as follows:

/// <summary>

/// Specifies valid values for text alignment

/// </summary>

public enum LabelTextAlignment : byte

{

/// <summary>

/// </summary>

Left = 0,

/// <summary>

/// </summary>

Center = 1,

/// <summary>

/// </summary>

Right = 2

}



Tomer.

Alex Feinman said:
How did you define your enum?

--
Alex Feinman
---
Visit http://www.opennetcf.org
Well it didn't work after all. Probably because of this error.

Any other suggestions?

Tomer.


Have you assigned a default value attribute to your designer, also
what about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type cannot
be
converted to target type" in the task list.
Also when I change the property value to something other then the
default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check
that in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 
T

Tomer

Thanks, I will follow these tips and keep you posted.

Peter Foot said:
I would recommend that you place the control and required enumeration in a
dll which you reference from your exe. That way you can keep the runtime
and designer dlls in sync - yes the version must match exactly - your
designer assembly includes a RuntimeAssemblyAttribute which determines the
dll which will provide the functionality for runtime, the signature of this
must match exactly with your runtime dll. Since an exe doesn't expose types
for external consumption you current setup is unsupported.

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Tomer said:
No its a new name. I've used LabelTextAlignment, and its publically
declared for both runtime and design time.
By the way I've no runtime dll, I'm compiling the controls with the main
executable.

Does the version numbering should cause trouble?

Thanks for the help!

Tomer.

Peter Foot said:
The name doesn't clash with an existing enumeration? it is publically
declared in both your runtime and designtime assemblies?

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

I've added the line and it solved the problem, now the enum value is
stored currectly (THANKS!!)

but I still get that error in the task list.

Tomer.


Have you assigned a default value attribute to your designer, also
what about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type cannot
be
converted to target type" in the task list.
Also when I change the property value to something other then the
default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check
that in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 
T

Tomer

It appears that it first solution DID work, but that was a test project, and
when I've run the "real" project it didn't.
I don't really know whats causing this, maybe because I'm working with
sourcesafe 6??? or maybe because this is a really big project??

Anyways thanks for the help, you too Peter.

Tomer.



Tomer said:
Thanks, I will follow these tips and keep you posted.

Alex Feinman said:
If what Peter suggested does not help by itself, try also changing the
enum not to derive from byte. Could be the designer does not like it.
Also, there is no or little point to using byte-based enum. All CPU
operations and registers are 32-bit, and the structure members are 32-bit
aligned as well. So unless you need a very large array of these values
(doesn't look like it), you are not gaining anything


--
Alex Feinman
---
Visit http://www.opennetcf.org
Tomer said:
I've defined it as follows:

/// <summary>

/// Specifies valid values for text alignment

/// </summary>

public enum LabelTextAlignment : byte

{

/// <summary>

/// </summary>

Left = 0,

/// <summary>

/// </summary>

Center = 1,

/// <summary>

/// </summary>

Right = 2

}



Tomer.

How did you define your enum?

--
Alex Feinman
---
Visit http://www.opennetcf.org
Well it didn't work after all. Probably because of this error.

Any other suggestions?

Tomer.


Have you assigned a default value attribute to your designer, also
what about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type cannot
be
converted to target type" in the task list.
Also when I change the property value to something other then the
default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check
that in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 
K

Keith Welch

If you define the enum in the class, it appears to confuse the designer.
This is true for desktop as well. Try defining it in the namespace outside
the class. Hope this helps.
Keith Welch
Mooseworks Software

Tomer said:
It appears that it first solution DID work, but that was a test project,
and when I've run the "real" project it didn't.
I don't really know whats causing this, maybe because I'm working with
sourcesafe 6??? or maybe because this is a really big project??

Anyways thanks for the help, you too Peter.

Tomer.



Tomer said:
Thanks, I will follow these tips and keep you posted.

Alex Feinman said:
If what Peter suggested does not help by itself, try also changing the
enum not to derive from byte. Could be the designer does not like it.
Also, there is no or little point to using byte-based enum. All CPU
operations and registers are 32-bit, and the structure members are
32-bit aligned as well. So unless you need a very large array of these
values (doesn't look like it), you are not gaining anything


--
Alex Feinman
---
Visit http://www.opennetcf.org
I've defined it as follows:

/// <summary>

/// Specifies valid values for text alignment

/// </summary>

public enum LabelTextAlignment : byte

{

/// <summary>

/// </summary>

Left = 0,

/// <summary>

/// </summary>

Center = 1,

/// <summary>

/// </summary>

Right = 2

}



Tomer.

How did you define your enum?

--
Alex Feinman
---
Visit http://www.opennetcf.org
Well it didn't work after all. Probably because of this error.

Any other suggestions?

Tomer.


Have you assigned a default value attribute to your designer, also
what about the designer serialization visibility e.g.:-

[DefaultValue(OpenNETCF.Drawing.ContentAlignment.MiddleCenter),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public virtual ContentAlignment Text Align
{


Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://blog.opennetcf.org/pfoot/

Hi,
I'm haviing a design time problem with a custom control I've wrote.

I've inherit from a label control, and added a new property called
TextAlignment.
And defined a new enum for it.

When I use it in the designer, I get the error : "object type
cannot be
converted to target type" in the task list.
Also when I change the property value to something other then the
default,
when I reopen the project the propery return to the default again.

I've read some posts on this problem and followed them, and check
that in
the bat file the order of the cf dlls are before the general ones.

Any help?

Tomer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top