Re: Tired. Annoyed. Really need help with Control serialization issues. Please...

From: Sky Sigal (aspforums_at_xact-solutions.removethis.com)
Date: 07/16/04


Date: Fri, 16 Jul 2004 15:44:07 +0200

Fair enough answer :-) ...although I thought that the example I posted WAS
the simpler version of what I am trying to get at in the long run...:-)

To rephrase(?) -- what I think I am fishing around for is a definite answer
to the following question:

a) I've seen that
[PersistenceMode(PersistenceMode.InnerProperty)]

[TypeConverter(typeof(StuffConverter))]
[PersistenceMode(PersistenceMode.InnerProperty)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

will work, putting into the html/xml of the control stuff like:
<mycontrol
    <MyProp
            MySubPropA="Uno"
            MySubPropA="Dos"
    />
...
/>

And I've seen that this can be set to .Attribute
[PersistenceMode(PersistenceMode.Attribute)]

if the propery is a non-complex type (string/int, etc).

But can it -- for SURE (ie bug is definatly on my side rather than a
limitation of the Framework) be that a complex type can be stored as an
attribute?

That's what I am trying to see. I think...(Could be a totally different
thing).

For example -- I am very mystified as to why the error happens at run-time.
Almost as if it is trying to serialize/send this to the outgoing HTML,
rather than take care of it in the IDE. Or is that it is hitting the
exception in the IDE -- but not flagging it as it is a different thread --
but that is why the IDE is not saving the changes back to the XML/HTML of
the control?

Voila.

If so -- could it be that the [Serialize()] attribute has nothing to do with
what I am working with and should be removed? Or am I missing a second half?
Some method that Serialize() will be looking for at run-time?

But yes -- today or this weekend I will try once again -- with an even
simpler TypeConverter -- something that parses a simpler string
"X=100;Y=200" or something like that...

Thanks for getting back to me btw :-)
Sky

"John Saunders" <johnwsaundersiii@notcoldmail.com> wrote in message
news:umljOvpaEHA.2892@TK2MSFTNGP10.phx.gbl...
> "Sky Sigal" <aspforums@xact-solutions.removethis.com> wrote in message
> news:%23OJ3FVbaEHA.996@TK2MSFTNGP12.phx.gbl...
> > I coming unglued... really need some help. 3 days chasing my tail all
over
> > MSDN's documentation ...and I'm getting nowhere.
> >
> > I have a problem with TypeConverters and
> > storage of expandableobjects to attributes in tags (think Style tag ->
> Style
> > object).
> >
> > The problem that I am chasing is:
> >
> > Html side:
> >
> > <CC1:MyControl id=whatever Stuff="A:Some stuff;B:Another value;C:Bad
hair
> > days"/>
> >
> >
> >
> > The code behind is 3 classes:
> > * cStuff which is a complex property -- an instance of a 3 string class:
> (A,
> > B,C);
> > * StuffConverter -- a TypeConverter enherited from
> ExpandableObjectConverter
> > that converts an instance of cStuff to
"key:value;key:value;key;value"...
> > (ie: Stuff="A:Some stuff;B:Another value;C:Bad hair days") and back
again.
> > * MyControl -- a generic test control to see how it works.
> > * Use of the following attributes on various elements, trying to keep it
> > glued together:
> > // [NotifyParentProperty(true)]
> > //[Serializable(),TypeConverter(typeof(StuffConverter))]
> > // [PersistenceMode(PersistenceMode.Attribute)]
> >
>
//[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
> >
> >
> >
> >
> > It doesn't matter what I do -- this is not working as expected.
> > There are 2 areas of error:
> >
> > a) In the IDE, it doesn't serialize the values back to the backend
> xml/html
> > attribute. I can edit both the backend tag -- or the IDE's property and
> it
> > renders it correctly in realtime. In other words it can string->object
> fine.
> > But it won't save it back to the html (serialize).
> >
> > b) Problem 2 -- when I run it I get a runtime error //Unable to generate
> > code for a value of type 'XAct.Web.Controls.cStuff'. This error occurred
> > while trying to generate the property value for Stuff.
> >
> >
> >
> > The closest match I have seen to a post/answer on the web is at
> > http://www.dotnet247.com/247reference/msgs/18/94895.aspx -- but I am not
> > sure if this applies since that was more complex and had to do with data
> > binding.
> >
> > Can any kind soul take a look at this? The code below should contain all
> > parts and be able to be dropped into one *.cs file to compile and test
as
> a
> > control.
>
> If I were you, I'd try simplifying the cStuff class down to a single
string,
> and with the TypeConverter attributes removed. If that works, try adding
the
> TypeConverter attributes, but change the TypeConverter to handle only a
> single string. If that works, add one more string...
> --
> John Saunders
> johnwsaundersiii at hotmail
>
>



Relevant Pages

  • RE: Complex data types in User-scoped ApplicationSettings
    ... serialize settings: ... If a TypeConverter exists that can convert to and from string, ... public class SerializableStringDictionary: StringDictionary, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Cannot stop command line build from AddIn
    ... method for command line build and "Build.Cancel" for IDE build. ... private AddIn addInInstance; ... public void BuildEvents_OnBuildProjConfigDone(string project, string ...
    (microsoft.public.dotnet.general)
  • Re: ?Propertygrid and dropdown list from database
    ... The thing is I want to use the same typeconverter to ... I have managed to get the dropdown list to work by making the string public. ... department options will be filled with employer types as well. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Trial version
    ... outside of the IDE than just running from inside the IDE. ... When you ported your .NET code to PureBasic you illustrated the slow string ... ; dblDouble = 9876.54321 ... For intDouble = 0 To 1000 ...
    (comp.lang.basic.powerbasic)
  • RE: problems with storing a custom type in application settings
    ... As mentioned in the FAQ article, one means is implementing a TypeConverter ... public class MySettingType ... private string _name; ... string str = value as string; ...
    (microsoft.public.dotnet.languages.csharp)