I have put some code together that creates an enum dynamically from some
database values.
The enum can be read perfectly by an application that references the
dynamically generated dll.
If I /emit/ a new version of the assembly, and start the application
again, the new values will appear for the enum.
However, suppose I want the application to remain in a running state.
Can I actually emit the newly generated dynamic dll into memory using
the IlGenerator? And, from that point on, will the application use the
new dynamically generated enum?
( From what I have read, it seems possible so long as the assembly is
generated in the same ApplicationDomain as the application. ) 8 2524
Hello
Yes it is possible to generate 2 assemblies in memory and have your
application reference types from both assemblies. To reference an assembly
it must be loaded in the same app domain as the referencing code. Note that
everytime you load a new assembly in an AppDomain it cannot be unloaded
unless you unload the AppDomain. I suggest that you create a new AppDomain
everytime you generate an assembly, and unload the AppDomain when you no
longer need it (after a new one is created for example)
Best regards,
Sherif
"Eyeawanda Pondicherry" <ou***********@us.india> wrote in message
news:jw****************@newsread3.news.pas.earthli nk.net... I have put some code together that creates an enum dynamically from some database values.
The enum can be read perfectly by an application that references the dynamically generated dll.
If I /emit/ a new version of the assembly, and start the application again, the new values will appear for the enum.
However, suppose I want the application to remain in a running state.
Can I actually emit the newly generated dynamic dll into memory using the IlGenerator? And, from that point on, will the application use the new dynamically generated enum?
( From what I have read, it seems possible so long as the assembly is generated in the same ApplicationDomain as the application. )
Thank you very much.
I need to read up on AppDomain, as I am not that familiar with the concept.
It sounds like /unloading/ the AppDomain is *not* the same as stopping the
application ?
So, if it were an exe referencing a dll, and the dll was dynamic and
changed, I would load both the exe and dll from one AppDomain to a new
AppDomain, and then shut down the old AppDomain ( unload it )?
Sherif ElMetainy wrote: Hello
Yes it is possible to generate 2 assemblies in memory and have your application reference types from both assemblies. To reference an assembly it must be loaded in the same app domain as the referencing code. Note that everytime you load a new assembly in an AppDomain it cannot be unloaded unless you unload the AppDomain. I suggest that you create a new AppDomain everytime you generate an assembly, and unload the AppDomain when you no longer need it (after a new one is created for example)
Best regards, Sherif
"Eyeawanda Pondicherry" <ou***********@us.india> wrote in message news:jw****************@newsread3.news.pas.earthli nk.net... I have put some code together that creates an enum dynamically from some database values.
The enum can be read perfectly by an application that references the dynamically generated dll.
If I /emit/ a new version of the assembly, and start the application again, the new values will appear for the enum.
However, suppose I want the application to remain in a running state.
Can I actually emit the newly generated dynamic dll into memory using the IlGenerator? And, from that point on, will the application use the new dynamically generated enum?
( From what I have read, it seems possible so long as the assembly is generated in the same ApplicationDomain as the application. )
-- http://kentpsychedelic.blogspot.com/
incognito, updated almost daily
Eyeawanda Pondicherry wrote: Can I actually emit the newly generated dynamic dll into memory using the IlGenerator? And, from that point on, will the application use the new dynamically generated enum?
Yes, you can Emit assemblies that get 'baked' into assemblies that you
can run immediately.
However, what does it mean to Emit an enum and use it immediately?
Without creating a saved assembly that you then reference and compile
against, you can't write code that refers to
MyDynamicEnum.SomeDynamicMember (ie, by name); you just have the Type
of the new enum, to use with methods like Enum.ToObject(). Yes, you
have a way to associate numeric values with strings, so that
ToString() on a dynamic enum type returns, say, "SomeDynamicMember"
instead of "42" - but, otherwise, isn't a dynamic enum just an slow
numeric type?
--
programmer, author http://www.midnightbeach.com
and father http://www.midnightbeach.com/hs
Well, here's what I'm doing, and it almost works, but not quite:
I strongly type the parameteres to a web method, initially I just hard coded
enums into the web service and used those to type my parameters...but I
want the values of the parameters to be dynamic, based on a database...
which will change ( not all the time, so there is a bit of latency ).
So, thanks to some help here, I created a dynamical assembly that contains
the enums and I reference it in the Web Service. These enums change as I
change each time I emit the dynamic assembly, and so the acceptable values
shown in the WSDL change ( which is very cool ). But this only happens if
I restart the web service.
That's good enough, but just to go for broke, I wonder if you can emit the
assemblies directly into memory, and have the web service pick up the
change without restarting it.
Jon Shemitz wrote: Eyeawanda Pondicherry wrote:
Can I actually emit the newly generated dynamic dll into memory using the IlGenerator? And, from that point on, will the application use the new dynamically generated enum?
Yes, you can Emit assemblies that get 'baked' into assemblies that you can run immediately.
However, what does it mean to Emit an enum and use it immediately? Without creating a saved assembly that you then reference and compile against, you can't write code that refers to MyDynamicEnum.SomeDynamicMember (ie, by name); you just have the Type of the new enum, to use with methods like Enum.ToObject(). Yes, you have a way to associate numeric values with strings, so that ToString() on a dynamic enum type returns, say, "SomeDynamicMember" instead of "42" - but, otherwise, isn't a dynamic enum just an slow numeric type?
-- http://kentpsychedelic.blogspot.com/
incognito, updated almost daily
Hello
The WSDL of the web service shouldn't change after the release of the web
service, because that would break the web service clients. The WSDL is a
contract. The web service client will not know that a new WSDL is available,
and could end up calling the web service with an enum value that was deleted
or renamed. I suggest that your web method accepts a string parameter
instead of the enum, and have the code in your method validate the string
against a database table. If you want the client to know the list of valid
values, you can have another web method called something like GetValidValues
that returns an array of strings with valid parameter values.
Best regards,
Sherif
"Existenz" <ga****@r.lamers> wrote in message
news:VK*****************@newsread1.news.pas.earthl ink.net... Well, here's what I'm doing, and it almost works, but not quite:
I strongly type the parameteres to a web method, initially I just hard
coded enums into the web service and used those to type my parameters...but I want the values of the parameters to be dynamic, based on a database... which will change ( not all the time, so there is a bit of latency ).
So, thanks to some help here, I created a dynamical assembly that contains the enums and I reference it in the Web Service. These enums change as I change each time I emit the dynamic assembly, and so the acceptable values shown in the WSDL change ( which is very cool ). But this only happens if I restart the web service.
That's good enough, but just to go for broke, I wonder if you can emit the assemblies directly into memory, and have the web service pick up the change without restarting it.
Jon Shemitz wrote:
Eyeawanda Pondicherry wrote:
Can I actually emit the newly generated dynamic dll into memory using the IlGenerator? And, from that point on, will the application use the new dynamically generated enum?
Yes, you can Emit assemblies that get 'baked' into assemblies that you can run immediately.
However, what does it mean to Emit an enum and use it immediately? Without creating a saved assembly that you then reference and compile against, you can't write code that refers to MyDynamicEnum.SomeDynamicMember (ie, by name); you just have the Type of the new enum, to use with methods like Enum.ToObject(). Yes, you have a way to associate numeric values with strings, so that ToString() on a dynamic enum type returns, say, "SomeDynamicMember" instead of "42" - but, otherwise, isn't a dynamic enum just an slow numeric type?
--
http://kentpsychedelic.blogspot.com/ incognito, updated almost daily
Good point on the contract aspect of WSDL.
However, a contract can be written so to specify that some element of
the contract will be a set of possible values, and those values may
change over time.
You see, 'breaking' the client is /exactly/ what I want to do -- this
prevents them from sending invalid data, *ever* to my web service.
Sherif ElMetainy wrote: Hello
The WSDL of the web service shouldn't change after the release of the web service, because that would break the web service clients. The WSDL is a contract. The web service client will not know that a new WSDL is available, and could end up calling the web service with an enum value that was deleted or renamed. I suggest that your web method accepts a string parameter instead of the enum, and have the code in your method validate the string against a database table. If you want the client to know the list of valid values, you can have another web method called something like GetValidValues that returns an array of strings with valid parameter values.
Best regards, Sherif "Existenz" <ga****@r.lamers> wrote in message news:VK*****************@newsread1.news.pas.earthl ink.net...
Well, here's what I'm doing, and it almost works, but not quite:
I strongly type the parameteres to a web method, initially I just hard
coded
enums into the web service and used those to type my parameters...but I want the values of the parameters to be dynamic, based on a database... which will change ( not all the time, so there is a bit of latency ).
So, thanks to some help here, I created a dynamical assembly that contains the enums and I reference it in the Web Service. These enums change as I change each time I emit the dynamic assembly, and so the acceptable values shown in the WSDL change ( which is very cool ). But this only happens if I restart the web service.
That's good enough, but just to go for broke, I wonder if you can emit the assemblies directly into memory, and have the web service pick up the change without restarting it.
Jon Shemitz wrote:
Eyeawanda Pondicherry wrote:
Can I actually emit the newly generated dynamic dll into memory using the IlGenerator? And, from that point on, will the application use the new dynamically generated enum?
Yes, you can Emit assemblies that get 'baked' into assemblies that you can run immediately.
However, what does it mean to Emit an enum and use it immediately? Without creating a saved assembly that you then reference and compile against, you can't write code that refers to MyDynamicEnum.SomeDynamicMember (ie, by name); you just have the Type of the new enum, to use with methods like Enum.ToObject(). Yes, you have a way to associate numeric values with strings, so that ToString() on a dynamic enum type returns, say, "SomeDynamicMember" instead of "42" - but, otherwise, isn't a dynamic enum just an slow numeric type?
--
http://kentpsychedelic.blogspot.com/ incognito, updated almost daily
Hello
As I said in my previous post, you can use a string parameter instead of
enum, check for the validity of the parameter and throw an exception if the
client sends an invalid string. This way the client cannot will not be able
to use the invalid value. You can provide the client with an alternative way
to get valid values by creating a method that returns an array of valid
values.
In your way everytime you change the WSDL, the client has to update its web
reference, and be recompiled (I am assuming a .NET client here). In my way
the client can doesn't have to be recompiled.
Best regards,
Sherif
"Super Fan" <ha***@win.next.year> wrote in message
news:Bw*****************@newsread1.news.pas.earthl ink.net... Good point on the contract aspect of WSDL.
However, a contract can be written so to specify that some element of the contract will be a set of possible values, and those values may change over time.
You see, 'breaking' the client is /exactly/ what I want to do -- this prevents them from sending invalid data, *ever* to my web service.
Sherif ElMetainy wrote: Hello
The WSDL of the web service shouldn't change after the release of the
web service, because that would break the web service clients. The WSDL is a contract. The web service client will not know that a new WSDL is
available, and could end up calling the web service with an enum value that was
deleted or renamed. I suggest that your web method accepts a string parameter instead of the enum, and have the code in your method validate the
string against a database table. If you want the client to know the list of
valid values, you can have another web method called something like
GetValidValues that returns an array of strings with valid parameter values.
Best regards, Sherif "Existenz" <ga****@r.lamers> wrote in message news:VK*****************@newsread1.news.pas.earthl ink.net...
Well, here's what I'm doing, and it almost works, but not quite:
I strongly type the parameteres to a web method, initially I just hard
coded
enums into the web service and used those to type my parameters...but I want the values of the parameters to be dynamic, based on a database... which will change ( not all the time, so there is a bit of latency ).
So, thanks to some help here, I created a dynamical assembly that
containsthe enums and I reference it in the Web Service. These enums change as
Ichange each time I emit the dynamic assembly, and so the acceptable
valuesshown in the WSDL change ( which is very cool ). But this only happens
ifI restart the web service.
That's good enough, but just to go for broke, I wonder if you can emit
theassemblies directly into memory, and have the web service pick up the change without restarting it.
Jon Shemitz wrote:
Eyeawanda Pondicherry wrote:
>Can I actually emit the newly generated dynamic dll into memory using >the IlGenerator? And, from that point on, will the application use
the>new dynamically generated enum?
Yes, you can Emit assemblies that get 'baked' into assemblies that you can run immediately.
However, what does it mean to Emit an enum and use it immediately? Without creating a saved assembly that you then reference and compile against, you can't write code that refers to MyDynamicEnum.SomeDynamicMember (ie, by name); you just have the Type of the new enum, to use with methods like Enum.ToObject(). Yes, you have a way to associate numeric values with strings, so that ToString() on a dynamic enum type returns, say, "SomeDynamicMember" instead of "42" - but, otherwise, isn't a dynamic enum just an slow numeric type?
--
http://kentpsychedelic.blogspot.com/ incognito, updated almost daily
The enums will not change that frequently.
Doing it your way, making a second web method call to the server for
each input parameter, introduces some very heavy overhead.
Whereas using enums, that can be called once by the client, and used
locally -- on the client thereafter -- and which also puts the burden of
supplying correct data before even making a round trip to my server --
well, you can see where enums can be attractive (!)
Sherif ElMetainy wrote: Hello
As I said in my previous post, you can use a string parameter instead of enum, check for the validity of the parameter and throw an exception if the client sends an invalid string. This way the client cannot will not be able to use the invalid value. You can provide the client with an alternative way to get valid values by creating a method that returns an array of valid values.
In your way everytime you change the WSDL, the client has to update its web reference, and be recompiled (I am assuming a .NET client here). In my way the client can doesn't have to be recompiled.
Best regards, Sherif
"Super Fan" <ha***@win.next.year> wrote in message news:Bw*****************@newsread1.news.pas.earthl ink.net...
Good point on the contract aspect of WSDL.
However, a contract can be written so to specify that some element of the contract will be a set of possible values, and those values may change over time.
You see, 'breaking' the client is /exactly/ what I want to do -- this prevents them from sending invalid data, *ever* to my web service.
Sherif ElMetainy wrote:
Hello
The WSDL of the web service shouldn't change after the release of the web service, because that would break the web service clients. The WSDL is a contract. The web service client will not know that a new WSDL is available, and could end up calling the web service with an enum value that was deleted or renamed. I suggest that your web method accepts a string parameter instead of the enum, and have the code in your method validate the string against a database table. If you want the client to know the list of valid values, you can have another web method called something like GetValidValues that returns an array of strings with valid parameter values.
Best regards, Sherif "Existenz" <ga****@r.lamers> wrote in message news:VK*****************@newsread1.news.pas.ear thlink.net...
Well, here's what I'm doing, and it almost works, but not quite:
I strongly type the parameteres to a web method, initially I just hard
coded
enums into the web service and used those to type my parameters...but I want the values of the parameters to be dynamic, based on a database... which will change ( not all the time, so there is a bit of latency ).
So, thanks to some help here, I created a dynamical assembly that contains the enums and I reference it in the Web Service. These enums change as I change each time I emit the dynamic assembly, and so the acceptable values shown in the WSDL change ( which is very cool ). But this only happens if I restart the web service.
That's good enough, but just to go for broke, I wonder if you can emit the assemblies directly into memory, and have the web service pick up the change without restarting it.
Jon Shemitz wrote: >Eyeawanda Pondicherry wrote: > > > >>Can I actually emit the newly generated dynamic dll into memory using >>the IlGenerator? And, from that point on, will the application use the new dynamically generated enum? > >Yes, you can Emit assemblies that get 'baked' into assemblies that you >can run immediately. > >However, what does it mean to Emit an enum and use it immediately? >Without creating a saved assembly that you then reference and compile >against, you can't write code that refers to >MyDynamicEnum.SomeDynamicMember (ie, by name); you just have the Type >of the new enum, to use with methods like Enum.ToObject(). Yes, you >have a way to associate numeric values with strings, so that >ToString() on a dynamic enum type returns, say, "SomeDynamicMember" >instead of "42" - but, otherwise, isn't a dynamic enum just an slow >numeric type? >
--
http://kentpsychedelic.blogspot.com/ incognito, updated almost daily
--
Go SeaHawks! Beat Saints! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Nigel Sampson |
last post by:
ey all,
I'm in the process of creating a method of
tracking whenever an objects properties are changed. Since
its not possible to alter
existing types I decided to used a proxy generated using...
|
by: DEK |
last post by:
I'm creating a dynamic assembly which has one type with one constructor,
the type inherits a base class Season, which is in the current assembly.
I am trying to emit a constructor which simply...
|
by: samlee |
last post by:
Hi All,
I'm learning how to write C# using reflection, but don't know how to
code using reflection
this.Controls.Add(this.label1);
Could anyone help, Thank in advance.
...
|
by: Matthias Klöpper |
last post by:
Hi there,
I'm currently trying to call some API-Functions via Reflection.Emit since I
need to bind to different dlls based on user input. The dynamic creation of
the required PInvoke-Methods works...
|
by: john |
last post by:
Hi,All MS Tech Gurus:
I need your help!!! It is the second time I post this message, I need get
some feedback ASAP, Please Help!!
Thanks a lot in advance.
John
I have a csharp method, using...
|
by: Luis Arvayo |
last post by:
Hi,
In c#, I need to dynamically create types at runtime that will consist of
the following:
- inherits from a given interface
- will have a constructor with an int argument
|
by: heddy |
last post by:
I understand that reflection allows me to discover the metadata of a
class at runtime (properties, methods etc). What I don't understand is
where this is useful. For example:
If I am the sole...
|
by: =?Utf-8?B?U2hhd24=?= |
last post by:
Hi;
i just started research reflection and i'm wondering if i have an empty
class file can i use reflection to add member variables and attributes
dynamically and then instantiate the class?
What...
|
by: Michael Sander |
last post by:
Hello ng,
anyone knowns how to add a reference to an assembly to
System.Reflection.AssemblyBuilder?
In System.Web.Compilation.AssemblyBuilder is a function like
AddAssemblyReference, but not in...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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...
|
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
|
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...
|
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: 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,...
|
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,...
|
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...
| |