George,
I sounds like you want an Add-in/Plug-in ability where the code is
dynamically compiled, rather then loaded from a pre-compiled assembly.
The following articles discusses loading plug-ins into AppDomains
http://msdn.microsoft.com/msdnmag/is...s/default.aspx
The following article discusses some security to using AddDomains:
http://msdn.microsoft.com/msdnmag/is...s/default.aspx
The following discusses what's new in CAS in .NET 2.0
http://msdn.microsoft.com/msdnmag/is...y/default.aspx
The following discuss what's new in .NET 2.0 for loading plug-ins into
AppDomains
http://msdn.microsoft.com/msdnmag/is...s/default.aspx
When you compile your dynamic code you can use
CompilerParameters.ReferencedAssemblies to reference the assembly with your
application's "object model" in it. I would make this "object model"
"hardened" as the above article articles suggest. Although using AppDomains
& an "hardened object model" is more work, it helps your app be more
resilient to problems in the dynamic code.
NOTE: You will need to compile the dynamic code in the sand boxed AppDomain
to ensure its isolated...
--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley -
http://www.tsbradley.net
"George Meng" <ge************@sohu.com> wrote in message
news:Og**************@TK2MSFTNGP15.phx.gbl...
| Thanks very much Jay, actually, I want to put this feature into multiple
| forms.
|
|
| "Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net>
дÈëÏûÏ¢ÐÂÎÅ
| :eu**************@TK2MSFTNGP15.phx.gbl...
| > George,
| > Another question.
| >
| > Is there only one form that you can add dynamic code to or are there
| > multiple forms that you add dynamic code to?
| >
| > --
| > Hope this helps
| > Jay [MVP - Outlook]
| > T.S. Bradley -
http://www.tsbradley.net
| >
| >
| > "George Meng" <ge************@sohu.com> wrote in message
| > news:ej*************@TK2MSFTNGP15.phx.gbl...
| > |I got a tough question:
| > |
| > | The backgroud for this question is:
| > | I want to design an application works like a engine.
| > | After release, we can still customize a form by adding a button, and
| > source
| > | code for the button. (This is done by the form itself, not by using
| > VS.Net)
| > | (button and source code should be a record in database, these
| information
| > | should be retrieve from database when the form shows up)
| > |
| > | What I want is:
| > | I want the source code (comes from database) to access other controls
| > which
| > | has already been in the form. For example:
| > | I want to read a item from a listbox (let's assume there is a listbox
| in
| > | the form)
| > | I want to add a item to a listbox
| > | I want to change the property of a datagrid
| > | ......
| > |
| > | What I can to do:
| > | 1) add a button on the fly
| > | 2) load source code from database for this button's click event
| > | 3) complie code on the fly.
| > |
| > | What I don't know:
| > | I don't knwo how to reference the form in the new code.
| > | I don't know how to reference the controls in the form.
| > |
| > | Thanks for any suggestions.
| > |
| > | George Meng
| > |
| > |
| >
| >
|
|