By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,685 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

beyond dynamic code execution

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
George,

You are not the first one who asks questions related to your approach in
this newsgroup.

Microsoft did it already and after long time of continuous improvement they
have now the current version of Office MS Access. It did cost Microsoft a
lot of money to come where they are now.

You will have to go that way as well. In my opinion is it asking to much
from a newsgroup to give the solution for that.

Keep in mind that your customers normaly will accept nothing less than a
solution as MS Access.

Just meant as warning to think about before you start.

Cor
Nov 21 '05 #2

P: n/a
Not sure what you are talking about.
I am using .Net, have nothing to do with Access.
I a short, my question is: how to reference other objects in a new dynamic
execution code.

George

"Cor Ligthert [MVP]" <no************@planet.nl> 写入消息新闻
:eV**************@TK2MSFTNGP14.phx.gbl...
George,

You are not the first one who asks questions related to your approach in
this newsgroup.

Microsoft did it already and after long time of continuous improvement they have now the current version of Office MS Access. It did cost Microsoft a
lot of money to come where they are now.

You will have to go that way as well. In my opinion is it asking to much
from a newsgroup to give the solution for that.

Keep in mind that your customers normaly will accept nothing less than a
solution as MS Access.

Just meant as warning to think about before you start.

Cor

Nov 21 '05 #3

P: n/a
George,
| 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.
The "easiest" way may be to define the dynamic code as inheriting from your
form. Alternatively you could define your dynamic code as accepting a
parameter of your form.

Thinking about it: the Separated Interface Pattern might be useful here.

http://www.martinfowler.com/eaaCatal...Interface.html
I would put the form or separated interface in its own class library, then
when I compile the dynamic code I would add a reference to the class
library.

I will see if I can come up with an example tomorrow.

Some questions:
- Is the definition of the form static? (other then the button you are
adding?)
- How is the dynamic code defined? (Is it a sub, function, class, something
else?)
- Is Code Access Security involved?
- How many buttons w/code can be added to a form? (

I believe Cor was referring to "full integration" where the users of your
app have complete control to customize the UI as Access does. You may want
to consider a product such as Microsoft Visual Studio 2005 Tools for
Applications if you are looking for significant user customization of your
UI.

http://msdn.microsoft.com/vstudio/ex...a/default.aspx
--
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
|
|
Nov 21 '05 #4

P: n/a
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
|
|
Nov 21 '05 #5

P: n/a
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
|
|

Nov 21 '05 #6

P: n/a
Jay,

I believe Cor was referring to "full integration" where the users of your
app have complete control to customize the UI as Access does. You may want
to consider a product such as Microsoft Visual Studio 2005 Tools for
Applications if you are looking for significant user customization of your
UI.
Exactly

:-)

http://msdn.microsoft.com/vstudio/ex...a/default.aspx

Exactly

:-)

Cor
Nov 21 '05 #7

P: n/a
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
| > |
| > |
| >
| >
|
|
Nov 21 '05 #8

P: n/a
Thanks so much Jay, I got the direction. I will try it.

"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> 写入消息新闻
:eo**************@TK2MSFTNGP15.phx.gbl...
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...ity/default.as
px
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
| > |
| > |
| >
| >
|
|

Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.