473,394 Members | 1,965 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,394 software developers and data experts.

Destroying emitted enumerations.

I have some code that creates dynamic enumerations for use in a PropertyGrid
control. This all works perfectly but the memory usage of the program
increases quite quicly when viewing the PropertyGrids displaying these
enumerations (one of which has a few hundred items in). I believe this is
because the dynamically generated enumerations are not being destroyed.

I have not been able to find a mechanism for deleting/destroying dynamically
generated enumerations so I decided to try to create them in a separate
AppDomain which could be unloaded when the enumerations were no longer
needed.

So I changed my code from: -

-> AppDomain ad = AppDomain.CurrentDomain;

to: -

-> AppDomain ad = AppDomain.CreateDomain( "EmittedTypes",
AppDomain.CurrentDomain.Evidence,
AppDomain.CurrentDomain.SetupInformation );

I thought this would create a new AppDomain into which I could place the
enumerations. It all works except for when I make the call: -

-> AssemblyBuilder ab = ad.DefineDynamicAssembly( an,
AssemblyBuilderAccess.RunAndSave );

With the error, "An unhandled exception of type
'System.Runtime.Serialization.SerializationExcepti on' occurred in
mscorlib.dll - Additional information: The type
System.Reflection.Emit.AssemblyBuilder in Assembly mscorlib,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 is not
marked as serializable.".

Any information that might point me in the right direction would be very
helpful.

Thank you in advance,

Jonathan Williamson

Nov 13 '05 #1
1 2124
Have you tried adding the Serialize attribute to the class in question?
Given the assembly, and the emitted class, all you have to do is add the
attribute when you call ModuleBuilder.DefineType.

This help?

Chris

"someone else" <jw********@hotmail.com> wrote in message
news:Fy*****************@newsfep2-win.server.ntli.net...
I have some code that creates dynamic enumerations for use in a PropertyGrid control. This all works perfectly but the memory usage of the program
increases quite quicly when viewing the PropertyGrids displaying these
enumerations (one of which has a few hundred items in). I believe this is
because the dynamically generated enumerations are not being destroyed.

I have not been able to find a mechanism for deleting/destroying dynamically generated enumerations so I decided to try to create them in a separate
AppDomain which could be unloaded when the enumerations were no longer
needed.

So I changed my code from: -

-> AppDomain ad = AppDomain.CurrentDomain;

to: -

-> AppDomain ad = AppDomain.CreateDomain( "EmittedTypes",
AppDomain.CurrentDomain.Evidence,
AppDomain.CurrentDomain.SetupInformation );

I thought this would create a new AppDomain into which I could place the
enumerations. It all works except for when I make the call: -

-> AssemblyBuilder ab = ad.DefineDynamicAssembly( an,
AssemblyBuilderAccess.RunAndSave );

With the error, "An unhandled exception of type
'System.Runtime.Serialization.SerializationExcepti on' occurred in
mscorlib.dll - Additional information: The type
System.Reflection.Emit.AssemblyBuilder in Assembly mscorlib,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 is not marked as serializable.".

Any information that might point me in the right direction would be very
helpful.

Thank you in advance,

Jonathan Williamson

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joyce | last post by:
In my schema I have 2 enumerations, let's say, country description and country code, and I want to use them so I can map each country description to its precise country code (and no other). So far...
0
by: Plinkerton | last post by:
I'm making an Base Class that will be inherited. In my base class, I have a public enumeration that defines a list of things I want my class to be able to do. I use it for Method input...
21
by: Christopher Benson-Manica | last post by:
I'll try to explain what I want to do: I have foo.h and foo.cpp. Units that include foo.h will define an enumeration bar: enum bar { typeNone, typeBaz, typeQuux, ... , count }; A method...
1
by: Oleg Ogurok | last post by:
Hi all, I've added a new DataSet (xsd file) to my project in VS.NET 2003. There I create a simple type as an enumeration of values. <xs:simpleType name="MyCustomType"> <xs:restriction...
4
by: ChrisB | last post by:
Hello: I will be creating 50+ enumerations related to a large number of classes that span a number of namespaces. I was wondering if there are any "best practices" when defining enumerations. ...
1
by: TR | last post by:
Is it possible for the developer to control how, say, a RadioButtonList is emitted? Could it be emitted as a <UL> instead of a <TABLE>? If possible, I'd be grateful for links that show examples of...
27
by: Ben Finney | last post by:
Antoon Pardon wrote: > I just downloaded your enum module for python > and played a bit with it. IMO some of the behaviour makes it less > usefull. Feedback is appreciated. I'm hoping to...
77
by: Ben Finney | last post by:
Howdy all, PEP 354: Enumerations in Python has been accepted as a draft PEP. The current version can be viewed online: <URL:http://www.python.org/peps/pep-0354.html> Here is the...
0
by: Paul | last post by:
Hi all, I have a fairly basic page with some text boxes, validators and submit buttons. I have "EnableClientScript" set to false for all the validators and "enableEventValidation" set to false...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...

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.