473,766 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Eval code and AppDomains

I have some complex logic which is fairly simply to build up into a string.
I needed a way to Eval this string and return a Boolean result.
This code works fine to achieve that goal.

My question is what happens to the dynamically created assembly when the
method is done running? Does GC take care of it?
Or is it stuck in RAM until the ASP.Net process is recycled?

This code executes pretty frequently (maybe 4 times per transaction) and I
am concerned that I could be eating up RAM and not releasing it in my
ASP.Net application.
I would hate to have code like this bring down the web server just because I
didn't clean it up correctly.

I took a quick look with Task Manager but when the code ran there was no new
process created. Is that because it is running inside the ASP.Net process?

I have seen a couple of posts that mention creating a separate appdomain to
handle this type of issue.
Is there some complete sample code somewhere that shows how to do this
without accidentally re-loading the dynamic assembly into the ASP.Net
process?

Thanks in advance for any help.

--
Joe Fallon

=============== =============== =============== =============== =============== =
====
My web page calls the dynamic assembly code like this: where sbCode is the
complex Boolean logic in String format.

Dim objEval As New EvalProvider
Dim objResult As Object = objEval.Eval(sb Code.ToString)

=============== =============== =============== =============== =============== =
====
Dynamic Assembly code:
=============== =============== =============== =============== =============== =
====
Imports Microsoft.Visua lBasic
Imports System
Imports System.Text
Imports System.CodeDom. Compiler
Imports System.Reflecti on
Imports System.IO

Namespace myNamespace

''' <summary>
''' Think about this: Your application does a lot of business logic, some
of which requires complicated logical strings of code
''' that may change over time to meet certain business conditions or
metadata. Wouldn't it be great if you could pull the most
''' current string of code to be run out of your database based on certain
stored procedure input parameters, and be sure it's run
''' and you get back the desired result? In fact, the returned string of
code may even be dynamically created based on some of the
''' input parameters from the sproc itself.
''' </summary>
'''
''' <remarks>
''' http://www.eggheadcafe.com/articles/20030908.asp
''' </remarks>

Public Class EvalProvider

Public Function Eval(ByVal vbCode As String) As Object
Dim c As VBCodeProvider = New VBCodeProvider
Dim icc As ICodeCompiler = c.CreateCompile r()
Dim cp As CompilerParamet ers = New CompilerParamet ers

'Note: this list much match the list of Imports in the sb.Append
below!!
cp.ReferencedAs semblies.Add("s ystem.dll")
cp.ReferencedAs semblies.Add("s ystem.data.dll" )
cp.ReferencedAs semblies.Add("s ystem.xml.dll")

cp.CompilerOpti ons = "/t:library"
cp.GenerateInMe mory = True

Dim sb As StringBuilder = New StringBuilder(" ")
sb.Append("Impo rts System" & vbCrLf)
sb.Append("Impo rts System.Data" & vbCrLf)
sb.Append("Impo rts System.Xml" & vbCrLf)
sb.Append("Name space myNamespace " & vbCrLf)
sb.Append("Clas s myDynamicLib " & vbCrLf)
sb.Append("publ ic function EvalCode() as Object " & vbCrLf)
sb.Append(vbCod e & vbCrLf)
sb.Append("End Function " & vbCrLf)
sb.Append("End Class " & vbCrLf)
sb.Append("End Namespace" & vbCrLf)

'to debug your eval string uncomment this line
'Debug.WriteLin e(sb.ToString() )

Dim cr As CompilerResults = icc.CompileAsse mblyFromSource( cp,
sb.ToString())
Dim a As System.Reflecti on.Assembly = cr.CompiledAsse mbly
Dim o As Object
Dim mi As MethodInfo
o = a.CreateInstanc e("myNamespace. myDynamicLib ")
Dim t As Type = o.GetType()
mi = t.GetMethod("Ev alCode")
Dim s As Object
s = mi.Invoke(o, Nothing)
Return s

End Function

End Class

End Namespace
=============== =============== =============== =============== =============== =
====

Nov 21 '05 #1
6 1191
Joe,

Without looking to deep or trying, would I set the class you use in a
component.

Cor
Nov 21 '05 #2
Joe,
This code executes pretty frequently (maybe 4 times per transaction) and I
am concerned that I could be eating up RAM and not releasing it in my
ASP.Net application. Concern! Are you creating a dynamic assembly 4 times per transaction? Isn't
that in itself causing a performance issue?

I would consider keeping a Hashtable matching code snippets (the vbCode
parameter) to the compiled Assembly. I would only create the compiled
assembly if it was not previous registered in my Hashtable. The caveat is
you would need to ensure the code is thread safe...

My other concern is if you compile the same snippet 4 times you actually
wind up with 4 "identical" yet individual compiled assemblies...
My question is what happens to the dynamically created assembly when the
method is done running? I would expect the assembly to remain in the current AppDomain until that
AppDomain is unloaded, You might be able to handle the
AppDomain.Assem blyLoad & AppDomain.Domai nUnload events to monitor its
lifetime.

Notice there is no AppDomain.Assem blyUnload event, as you cannot unload
assemblies from an AppDomain without unloading the entire AppDomain.
Or is it stuck in RAM until the ASP.Net process is recycled? Based on how other assemblies work with an AppDomain that is correct.

Is there some complete sample code somewhere that shows how to do this
without accidentally re-loading the dynamic assembly into the ASP.Net
process? I don't have a specific link to a complete sample, however you should be
able to create a "EvalProvid er" AppDomain, load & instantiate "EvalProvid er"
class & assembly in this second AppDomain, when you call EvalProvider.Ev al
it should run in this second AppDomain.

The following might get you started:

http://msdn.microsoft.com/library/de...rp05162002.asp

Its C#, however it should be easily converted to VB.NET, post if you need
help.

One last item: The other major advantage of running the snippets
(EvalProvider.E val) in its own AddDomain is that you can "lock down"
(security wise/permission wise) that AppDomain so that the snippet cannot do
stuff its not suppose to. Depending on who is writing the snippets this can
be a good thing :-)

Hope this helps
Jay
"Joe Fallon" <jf******@nospa mtwcny.rr.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .I have some complex logic which is fairly simply to build up into a
string.
I needed a way to Eval this string and return a Boolean result.
This code works fine to achieve that goal.

My question is what happens to the dynamically created assembly when the
method is done running? Does GC take care of it?
Or is it stuck in RAM until the ASP.Net process is recycled?

This code executes pretty frequently (maybe 4 times per transaction) and I
am concerned that I could be eating up RAM and not releasing it in my
ASP.Net application.
I would hate to have code like this bring down the web server just because
I
didn't clean it up correctly.

I took a quick look with Task Manager but when the code ran there was no
new
process created. Is that because it is running inside the ASP.Net
process?

I have seen a couple of posts that mention creating a separate appdomain
to
handle this type of issue.
Is there some complete sample code somewhere that shows how to do this
without accidentally re-loading the dynamic assembly into the ASP.Net
process?

Thanks in advance for any help.

--
Joe Fallon

=============== =============== =============== =============== =============== =
====
My web page calls the dynamic assembly code like this: where sbCode is the
complex Boolean logic in String format.

Dim objEval As New EvalProvider
Dim objResult As Object = objEval.Eval(sb Code.ToString)

=============== =============== =============== =============== =============== =
====
Dynamic Assembly code:
=============== =============== =============== =============== =============== =
====
Imports Microsoft.Visua lBasic
Imports System
Imports System.Text
Imports System.CodeDom. Compiler
Imports System.Reflecti on
Imports System.IO

Namespace myNamespace

''' <summary>
''' Think about this: Your application does a lot of business logic, some
of which requires complicated logical strings of code
''' that may change over time to meet certain business conditions or
metadata. Wouldn't it be great if you could pull the most
''' current string of code to be run out of your database based on
certain
stored procedure input parameters, and be sure it's run
''' and you get back the desired result? In fact, the returned string of
code may even be dynamically created based on some of the
''' input parameters from the sproc itself.
''' </summary>
'''
''' <remarks>
''' http://www.eggheadcafe.com/articles/20030908.asp
''' </remarks>

Public Class EvalProvider

Public Function Eval(ByVal vbCode As String) As Object
Dim c As VBCodeProvider = New VBCodeProvider
Dim icc As ICodeCompiler = c.CreateCompile r()
Dim cp As CompilerParamet ers = New CompilerParamet ers

'Note: this list much match the list of Imports in the sb.Append
below!!
cp.ReferencedAs semblies.Add("s ystem.dll")
cp.ReferencedAs semblies.Add("s ystem.data.dll" )
cp.ReferencedAs semblies.Add("s ystem.xml.dll")

cp.CompilerOpti ons = "/t:library"
cp.GenerateInMe mory = True

Dim sb As StringBuilder = New StringBuilder(" ")
sb.Append("Impo rts System" & vbCrLf)
sb.Append("Impo rts System.Data" & vbCrLf)
sb.Append("Impo rts System.Xml" & vbCrLf)
sb.Append("Name space myNamespace " & vbCrLf)
sb.Append("Clas s myDynamicLib " & vbCrLf)
sb.Append("publ ic function EvalCode() as Object " & vbCrLf)
sb.Append(vbCod e & vbCrLf)
sb.Append("End Function " & vbCrLf)
sb.Append("End Class " & vbCrLf)
sb.Append("End Namespace" & vbCrLf)

'to debug your eval string uncomment this line
'Debug.WriteLin e(sb.ToString() )

Dim cr As CompilerResults = icc.CompileAsse mblyFromSource( cp,
sb.ToString())
Dim a As System.Reflecti on.Assembly = cr.CompiledAsse mbly
Dim o As Object
Dim mi As MethodInfo
o = a.CreateInstanc e("myNamespace. myDynamicLib ")
Dim t As Type = o.GetType()
mi = t.GetMethod("Ev alCode")
Dim s As Object
s = mi.Invoke(o, Nothing)
Return s

End Function

End Class

End Namespace
=============== =============== =============== =============== =============== =
====


Nov 21 '05 #3
Jay,
Thanks for your input. You have helped me a lot in the past. I really
appreciate it.

0. BTW this dynamic assembly code only runs on a single page in a large web
site when a user enters a complex transaction. So I am not overly concerned
about it scaling (yet) since this will be a small percentage of the total
hits on the site.

1. Do you know of any other way to Eval a String to get a Boolean result
other
than dynamically generating the assembly as shown below?

e.g. If I have a string such as "1=1" and I try to Cbool it I will get an
error.
Cbool("1=1") - error!

But Cbool(1=1) will return True. (Note that this is not a string!)

So the all the dynamic assembly does is execute my string and return T/F.

This is the core of the dynamic code which is executed:
Dim boolResult As Boolean = Cbool((1=1))
Return boolResult
Notice how my original string is now represented as something that will
evaluate correctly.

So, if there is some other way to get the same result I would like to know
about it.

FYI - I have some complex rules that become simple to code as a long Boolean
string which when evaluated returns T/F which is the only result I really
need. When I tried coding these complex rules without building up a string
it quickly got unmanageable. There was a huge advantage to building a string
in the code. But now Evaling the string with a dynamic asembly seems to be
an issue.

2. Do you know if Eval will be a built-in function in ver 2.0 of the .Net
framework?

3. Good point about the Hashtable. If it stored both the string and the
result then it could act as a cache and dramatically reduce the dynamic
assembly creation by simply retrieving the result for each matching string
that has been previously computed. I think there would be a large number of
matches since the rules would not change that frequently and so the strings
would tend to be repeated for each transaction type.

4. The hashtable resolves the point about compiling the same snippet 4 times
and creating 4 identical asemblies.
The original idea was to create the dynamic assembly and just "throw it
away" when it Eval(uated) the snippet.
But as I read more about it I learned you can't unload an assembly and so I
became concerned that I would be needlessly wasting memory. As I understand
it, ASP.Net monitors its AppDomain for "memory pressure" among other things
and will tear it down and build a new one automatically. I guess my dynamic
asemblies would just cause it to do this more frequently. Agree?

5. Rick Strahl's article showed how to create a separate appdomain. I
downloaded his code and got it working within the current appdomain but it
failed when trying to create a new one. Interestingly, he was working on the
exact same issue today and had MS Support on the line for 2 hours until the
figured out the problem. Sounds like the same problem I was having with his
code so I am hoping I can get it working tomorrow. This is a very tricky
issue. Lots of people talk about it but Rick was the only one who tried to
abstract the problem and create a class that shows how to do it. MS should
do this since they are the ones who know what works and what doesn't. The
documentation is a bit sketchy and without MS Support help Rick wouldn't
have solved it either since there were no errors returned from the code.

6. Good point on the security of a separate AppDomain.

7. I was considering setting a variable (count of hashtable?) that would
count the number of times I dynamically executed a snippet. When it exceeded
a certain threshhold I planned to tear down the separate AppDomain and start
over. Agree?

8. Since I am running in ASP.Net I would like to use the Cache to store the
hashtable. But the problem is the dynamic eval code is not in my code behind
pages. It is in my Business Object tier and that does not know anything
about the ASP.Net Cache. Any recommendations on how to store this hashtable
in my BO tier so that I will always have access to it?

Thanks!
--
Joe Fallon

"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Joe,
This code executes pretty frequently (maybe 4 times per transaction) and
I
am concerned that I could be eating up RAM and not releasing it in my
ASP.Net application.

Concern! Are you creating a dynamic assembly 4 times per transaction?
Isn't that in itself causing a performance issue?

I would consider keeping a Hashtable matching code snippets (the vbCode
parameter) to the compiled Assembly. I would only create the compiled
assembly if it was not previous registered in my Hashtable. The caveat is
you would need to ensure the code is thread safe...

My other concern is if you compile the same snippet 4 times you actually
wind up with 4 "identical" yet individual compiled assemblies...
My question is what happens to the dynamically created assembly when the
method is done running?

I would expect the assembly to remain in the current AppDomain until that
AppDomain is unloaded, You might be able to handle the
AppDomain.Assem blyLoad & AppDomain.Domai nUnload events to monitor its
lifetime.

Notice there is no AppDomain.Assem blyUnload event, as you cannot unload
assemblies from an AppDomain without unloading the entire AppDomain.
Or is it stuck in RAM until the ASP.Net process is recycled?

Based on how other assemblies work with an AppDomain that is correct.

Is there some complete sample code somewhere that shows how to do this
without accidentally re-loading the dynamic assembly into the ASP.Net
process?

I don't have a specific link to a complete sample, however you should be
able to create a "EvalProvid er" AppDomain, load & instantiate
"EvalProvid er" class & assembly in this second AppDomain, when you call
EvalProvider.Ev al it should run in this second AppDomain.

The following might get you started:

http://msdn.microsoft.com/library/de...rp05162002.asp

Its C#, however it should be easily converted to VB.NET, post if you need
help.

One last item: The other major advantage of running the snippets
(EvalProvider.E val) in its own AddDomain is that you can "lock down"
(security wise/permission wise) that AppDomain so that the snippet cannot
do stuff its not suppose to. Depending on who is writing the snippets this
can be a good thing :-)

Hope this helps
Jay
"Joe Fallon" <jf******@nospa mtwcny.rr.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
I have some complex logic which is fairly simply to build up into a
string.
I needed a way to Eval this string and return a Boolean result.
This code works fine to achieve that goal.

My question is what happens to the dynamically created assembly when the
method is done running? Does GC take care of it?
Or is it stuck in RAM until the ASP.Net process is recycled?

This code executes pretty frequently (maybe 4 times per transaction) and
I
am concerned that I could be eating up RAM and not releasing it in my
ASP.Net application.
I would hate to have code like this bring down the web server just
because I
didn't clean it up correctly.

I took a quick look with Task Manager but when the code ran there was no
new
process created. Is that because it is running inside the ASP.Net
process?

I have seen a couple of posts that mention creating a separate appdomain
to
handle this type of issue.
Is there some complete sample code somewhere that shows how to do this
without accidentally re-loading the dynamic assembly into the ASP.Net
process?

Thanks in advance for any help.

--
Joe Fallon

=============== =============== =============== =============== =============== =
====
My web page calls the dynamic assembly code like this: where sbCode is
the
complex Boolean logic in String format.

Dim objEval As New EvalProvider
Dim objResult As Object = objEval.Eval(sb Code.ToString)

=============== =============== =============== =============== =============== =
====
Dynamic Assembly code:
=============== =============== =============== =============== =============== =
====
Imports Microsoft.Visua lBasic
Imports System
Imports System.Text
Imports System.CodeDom. Compiler
Imports System.Reflecti on
Imports System.IO

Namespace myNamespace

''' <summary>
''' Think about this: Your application does a lot of business logic,
some
of which requires complicated logical strings of code
''' that may change over time to meet certain business conditions or
metadata. Wouldn't it be great if you could pull the most
''' current string of code to be run out of your database based on
certain
stored procedure input parameters, and be sure it's run
''' and you get back the desired result? In fact, the returned string of
code may even be dynamically created based on some of the
''' input parameters from the sproc itself.
''' </summary>
'''
''' <remarks>
''' http://www.eggheadcafe.com/articles/20030908.asp
''' </remarks>

Public Class EvalProvider

Public Function Eval(ByVal vbCode As String) As Object
Dim c As VBCodeProvider = New VBCodeProvider
Dim icc As ICodeCompiler = c.CreateCompile r()
Dim cp As CompilerParamet ers = New CompilerParamet ers

'Note: this list much match the list of Imports in the sb.Append
below!!
cp.ReferencedAs semblies.Add("s ystem.dll")
cp.ReferencedAs semblies.Add("s ystem.data.dll" )
cp.ReferencedAs semblies.Add("s ystem.xml.dll")

cp.CompilerOpti ons = "/t:library"
cp.GenerateInMe mory = True

Dim sb As StringBuilder = New StringBuilder(" ")
sb.Append("Impo rts System" & vbCrLf)
sb.Append("Impo rts System.Data" & vbCrLf)
sb.Append("Impo rts System.Xml" & vbCrLf)
sb.Append("Name space myNamespace " & vbCrLf)
sb.Append("Clas s myDynamicLib " & vbCrLf)
sb.Append("publ ic function EvalCode() as Object " & vbCrLf)
sb.Append(vbCod e & vbCrLf)
sb.Append("End Function " & vbCrLf)
sb.Append("End Class " & vbCrLf)
sb.Append("End Namespace" & vbCrLf)

'to debug your eval string uncomment this line
'Debug.WriteLin e(sb.ToString() )

Dim cr As CompilerResults = icc.CompileAsse mblyFromSource( cp,
sb.ToString())
Dim a As System.Reflecti on.Assembly = cr.CompiledAsse mbly
Dim o As Object
Dim mi As MethodInfo
o = a.CreateInstanc e("myNamespace. myDynamicLib ")
Dim t As Type = o.GetType()
mi = t.GetMethod("Ev alCode")
Dim s As Object
s = mi.Invoke(o, Nothing)
Return s

End Function

End Class

End Namespace
=============== =============== =============== =============== =============== =
====



Nov 21 '05 #4
Jay,
Thanks for your input. You have helped me a lot in the past. I really
appreciate it.

0. BTW this dynamic assembly code only runs on a single page in a large web
site when a user enters a complex transaction. So I am not overly concerned
about it scaling (yet) since this will be a small percentage of the total
hits on the site.

1. Do you know of any other way to Eval a String to get a Boolean result
other
than dynamically generating the assembly as shown below?

e.g. If I have a string such as "1=1" and I try to Cbool it I will get an
error.
Cbool("1=1") - error!

But Cbool(1=1) will return True. (Note that this is not a string!)

So the all the dynamic assembly does is execute my string and return T/F.

This is the core of the dynamic code which is executed:
Dim boolResult As Boolean = Cbool((1=1))
Return boolResult
Notice how my original string is now represented as something that will
evaluate correctly.

So, if there is some other way to get the same result I would like to know
about it.

FYI - I have some complex rules that become simple to code as a long Boolean
string which when evaluated returns T/F which is the only result I really
need. When I tried coding these complex rules without building up a string
it quickly got unmanageable. There was a huge advantage to building a string
in the code. But now Evaling the string with a dynamic asembly seems to be
an issue.

2. Do you know if Eval will be a built-in function in ver 2.0 of the .Net
framework?

3. Good point about the Hashtable. If it stored both the string and the
result then it could act as a cache and dramatically reduce the dynamic
assembly creation by simply retrieving the result for each matching string
that has been previously computed. I think there would be a large number of
matches since the rules would not change that frequently and so the strings
would tend to be repeated for each transaction type.

4. The hashtable resolves the point about compiling the same snippet 4 times
and creating 4 identical asemblies.
The original idea was to create the dynamic assembly and just "throw it
away" when it Eval(uated) the snippet.
But as I read more about it I learned you can't unload an assembly and so I
became concerned that I would be needlessly wasting memory. As I understand
it, ASP.Net monitors its AppDomain for "memory pressure" among other things
and will tear it down and build a new one automatically. I guess my dynamic
asemblies would just cause it to do this more frequently. Agree?

5. Rick Strahl's article showed how to create a separate appdomain. I
downloaded his code and got it working within the current appdomain but it
failed when trying to create a new one. Interestingly, he was working on the
exact same issue today and had MS Support on the line for 2 hours until the
figured out the problem. Sounds like the same problem I was having with his
code so I am hoping I can get it working tomorrow. This is a very tricky
issue. Lots of people talk about it but Rick was the only one who tried to
abstract the problem and create a class that shows how to do it. MS should
do this since they are the ones who know what works and what doesn't. The
documentation is a bit sketchy and without MS Support help Rick wouldn't
have solved it either since there were no errors returned from the code.

6. Good point on the security of a separate AppDomain.

7. I was considering setting a variable (count of hashtable?) that would
count the number of times I dynamically executed a snippet. When it exceeded
a certain threshhold I planned to tear down the separate AppDomain and start
over. Agree?

8. Since I am running in ASP.Net I would like to use the Cache to store the
hashtable. But the problem is the dynamic eval code is not in my code behind
pages. It is in my Business Object tier and that does not know anything
about the ASP.Net Cache. Any recommendations on how to store this hashtable
in my BO tier so that I will always have access to it?

Thanks!
--
Joe Fallon

"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Joe,
This code executes pretty frequently (maybe 4 times per transaction) and
I
am concerned that I could be eating up RAM and not releasing it in my
ASP.Net application.

Concern! Are you creating a dynamic assembly 4 times per transaction?
Isn't that in itself causing a performance issue?

I would consider keeping a Hashtable matching code snippets (the vbCode
parameter) to the compiled Assembly. I would only create the compiled
assembly if it was not previous registered in my Hashtable. The caveat is
you would need to ensure the code is thread safe...

My other concern is if you compile the same snippet 4 times you actually
wind up with 4 "identical" yet individual compiled assemblies...
My question is what happens to the dynamically created assembly when the
method is done running?

I would expect the assembly to remain in the current AppDomain until that
AppDomain is unloaded, You might be able to handle the
AppDomain.Assem blyLoad & AppDomain.Domai nUnload events to monitor its
lifetime.

Notice there is no AppDomain.Assem blyUnload event, as you cannot unload
assemblies from an AppDomain without unloading the entire AppDomain.
Or is it stuck in RAM until the ASP.Net process is recycled?

Based on how other assemblies work with an AppDomain that is correct.

Is there some complete sample code somewhere that shows how to do this
without accidentally re-loading the dynamic assembly into the ASP.Net
process?

I don't have a specific link to a complete sample, however you should be
able to create a "EvalProvid er" AppDomain, load & instantiate
"EvalProvid er" class & assembly in this second AppDomain, when you call
EvalProvider.Ev al it should run in this second AppDomain.

The following might get you started:

http://msdn.microsoft.com/library/de...rp05162002.asp

Its C#, however it should be easily converted to VB.NET, post if you need
help.

One last item: The other major advantage of running the snippets
(EvalProvider.E val) in its own AddDomain is that you can "lock down"
(security wise/permission wise) that AppDomain so that the snippet cannot
do stuff its not suppose to. Depending on who is writing the snippets this
can be a good thing :-)

Hope this helps
Jay
"Joe Fallon" <jf******@nospa mtwcny.rr.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
I have some complex logic which is fairly simply to build up into a
string.
I needed a way to Eval this string and return a Boolean result.
This code works fine to achieve that goal.

My question is what happens to the dynamically created assembly when the
method is done running? Does GC take care of it?
Or is it stuck in RAM until the ASP.Net process is recycled?

This code executes pretty frequently (maybe 4 times per transaction) and
I
am concerned that I could be eating up RAM and not releasing it in my
ASP.Net application.
I would hate to have code like this bring down the web server just
because I
didn't clean it up correctly.

I took a quick look with Task Manager but when the code ran there was no
new
process created. Is that because it is running inside the ASP.Net
process?

I have seen a couple of posts that mention creating a separate appdomain
to
handle this type of issue.
Is there some complete sample code somewhere that shows how to do this
without accidentally re-loading the dynamic assembly into the ASP.Net
process?

Thanks in advance for any help.

--
Joe Fallon

=============== =============== =============== =============== =============== =
====
My web page calls the dynamic assembly code like this: where sbCode is
the
complex Boolean logic in String format.

Dim objEval As New EvalProvider
Dim objResult As Object = objEval.Eval(sb Code.ToString)

=============== =============== =============== =============== =============== =
====
Dynamic Assembly code:
=============== =============== =============== =============== =============== =
====
Imports Microsoft.Visua lBasic
Imports System
Imports System.Text
Imports System.CodeDom. Compiler
Imports System.Reflecti on
Imports System.IO

Namespace myNamespace

''' <summary>
''' Think about this: Your application does a lot of business logic,
some
of which requires complicated logical strings of code
''' that may change over time to meet certain business conditions or
metadata. Wouldn't it be great if you could pull the most
''' current string of code to be run out of your database based on
certain
stored procedure input parameters, and be sure it's run
''' and you get back the desired result? In fact, the returned string of
code may even be dynamically created based on some of the
''' input parameters from the sproc itself.
''' </summary>
'''
''' <remarks>
''' http://www.eggheadcafe.com/articles/20030908.asp
''' </remarks>

Public Class EvalProvider

Public Function Eval(ByVal vbCode As String) As Object
Dim c As VBCodeProvider = New VBCodeProvider
Dim icc As ICodeCompiler = c.CreateCompile r()
Dim cp As CompilerParamet ers = New CompilerParamet ers

'Note: this list much match the list of Imports in the sb.Append
below!!
cp.ReferencedAs semblies.Add("s ystem.dll")
cp.ReferencedAs semblies.Add("s ystem.data.dll" )
cp.ReferencedAs semblies.Add("s ystem.xml.dll")

cp.CompilerOpti ons = "/t:library"
cp.GenerateInMe mory = True

Dim sb As StringBuilder = New StringBuilder(" ")
sb.Append("Impo rts System" & vbCrLf)
sb.Append("Impo rts System.Data" & vbCrLf)
sb.Append("Impo rts System.Xml" & vbCrLf)
sb.Append("Name space myNamespace " & vbCrLf)
sb.Append("Clas s myDynamicLib " & vbCrLf)
sb.Append("publ ic function EvalCode() as Object " & vbCrLf)
sb.Append(vbCod e & vbCrLf)
sb.Append("End Function " & vbCrLf)
sb.Append("End Class " & vbCrLf)
sb.Append("End Namespace" & vbCrLf)

'to debug your eval string uncomment this line
'Debug.WriteLin e(sb.ToString() )

Dim cr As CompilerResults = icc.CompileAsse mblyFromSource( cp,
sb.ToString())
Dim a As System.Reflecti on.Assembly = cr.CompiledAsse mbly
Dim o As Object
Dim mi As MethodInfo
o = a.CreateInstanc e("myNamespace. myDynamicLib ")
Dim t As Type = o.GetType()
mi = t.GetMethod("Ev alCode")
Dim s As Object
s = mi.Invoke(o, Nothing)
Return s

End Function

End Class

End Namespace
=============== =============== =============== =============== =============== =
====



Nov 21 '05 #5
Joe,
1. Do you know of any other way to Eval a String to get a Boolean result JavaScript as Scott shows in the microsoft.publi c.dotnet.framew ork.aspnet
newsgroup (not sure how this (languages.vb) newsgroup got left off that half
of this thread).

Alternatively you could use a computed column in a DataTable, if your data
is not already in a DataTable this may not work very well... The Expresssion
syntax in the DataSet OM is closer to VB, then JavaScripts, however with
limits.

http://msdn.microsoft.com/library/de...ssiontopic.asp
2. Do you know if Eval will be a built-in function in ver 2.0 of the .Net
framework? Not that I know of
8. Since I am running in ASP.Net I would like to use the Cache to store
the I have not looked at it a lot, there is the Caching Application Block
http://msdn.microsoft.com/library/de...chingblock.asp.

I normally simply keep the values in a Shared variables, however there is no
getting ride of old one...

Hope this helps
Jay

"Joe Fallon" <jf******@nospa mtwcny.rr.com> wrote in message
news:eO******** ******@TK2MSFTN GP09.phx.gbl... Jay,
Thanks for your input. You have helped me a lot in the past. I really
appreciate it.

0. BTW this dynamic assembly code only runs on a single page in a large
web site when a user enters a complex transaction. So I am not overly
concerned about it scaling (yet) since this will be a small percentage of
the total hits on the site.

1. Do you know of any other way to Eval a String to get a Boolean result
other
than dynamically generating the assembly as shown below?

e.g. If I have a string such as "1=1" and I try to Cbool it I will get an
error.
Cbool("1=1") - error!

But Cbool(1=1) will return True. (Note that this is not a string!)

So the all the dynamic assembly does is execute my string and return T/F.

This is the core of the dynamic code which is executed:
Dim boolResult As Boolean = Cbool((1=1))
Return boolResult
Notice how my original string is now represented as something that will
evaluate correctly.

So, if there is some other way to get the same result I would like to know
about it.

FYI - I have some complex rules that become simple to code as a long
Boolean string which when evaluated returns T/F which is the only result I
really need. When I tried coding these complex rules without building up a
string it quickly got unmanageable. There was a huge advantage to building
a string in the code. But now Evaling the string with a dynamic asembly
seems to be an issue.

2. Do you know if Eval will be a built-in function in ver 2.0 of the .Net
framework?

3. Good point about the Hashtable. If it stored both the string and the
result then it could act as a cache and dramatically reduce the dynamic
assembly creation by simply retrieving the result for each matching string
that has been previously computed. I think there would be a large number
of matches since the rules would not change that frequently and so the
strings would tend to be repeated for each transaction type.

4. The hashtable resolves the point about compiling the same snippet 4
times and creating 4 identical asemblies.
The original idea was to create the dynamic assembly and just "throw it
away" when it Eval(uated) the snippet.
But as I read more about it I learned you can't unload an assembly and so
I became concerned that I would be needlessly wasting memory. As I
understand it, ASP.Net monitors its AppDomain for "memory pressure" among
other things and will tear it down and build a new one automatically. I
guess my dynamic asemblies would just cause it to do this more frequently.
Agree?

5. Rick Strahl's article showed how to create a separate appdomain. I
downloaded his code and got it working within the current appdomain but it
failed when trying to create a new one. Interestingly, he was working on
the exact same issue today and had MS Support on the line for 2 hours
until the figured out the problem. Sounds like the same problem I was
having with his code so I am hoping I can get it working tomorrow. This is
a very tricky issue. Lots of people talk about it but Rick was the only
one who tried to abstract the problem and create a class that shows how to
do it. MS should do this since they are the ones who know what works and
what doesn't. The documentation is a bit sketchy and without MS Support
help Rick wouldn't have solved it either since there were no errors
returned from the code.

6. Good point on the security of a separate AppDomain.

7. I was considering setting a variable (count of hashtable?) that would
count the number of times I dynamically executed a snippet. When it
exceeded a certain threshhold I planned to tear down the separate
AppDomain and start over. Agree?

8. Since I am running in ASP.Net I would like to use the Cache to store
the hashtable. But the problem is the dynamic eval code is not in my code
behind pages. It is in my Business Object tier and that does not know
anything about the ASP.Net Cache. Any recommendations on how to store this
hashtable in my BO tier so that I will always have access to it?

Thanks!
--
Joe Fallon

"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Joe,
This code executes pretty frequently (maybe 4 times per transaction) and
I
am concerned that I could be eating up RAM and not releasing it in my
ASP.Net application.

Concern! Are you creating a dynamic assembly 4 times per transaction?
Isn't that in itself causing a performance issue?

I would consider keeping a Hashtable matching code snippets (the vbCode
parameter) to the compiled Assembly. I would only create the compiled
assembly if it was not previous registered in my Hashtable. The caveat is
you would need to ensure the code is thread safe...

My other concern is if you compile the same snippet 4 times you actually
wind up with 4 "identical" yet individual compiled assemblies...
My question is what happens to the dynamically created assembly when the
method is done running?

I would expect the assembly to remain in the current AppDomain until that
AppDomain is unloaded, You might be able to handle the
AppDomain.Assem blyLoad & AppDomain.Domai nUnload events to monitor its
lifetime.

Notice there is no AppDomain.Assem blyUnload event, as you cannot unload
assemblies from an AppDomain without unloading the entire AppDomain.
Or is it stuck in RAM until the ASP.Net process is recycled?

Based on how other assemblies work with an AppDomain that is correct.

Is there some complete sample code somewhere that shows how to do this
without accidentally re-loading the dynamic assembly into the ASP.Net
process?

I don't have a specific link to a complete sample, however you should be
able to create a "EvalProvid er" AppDomain, load & instantiate
"EvalProvid er" class & assembly in this second AppDomain, when you call
EvalProvider.Ev al it should run in this second AppDomain.

The following might get you started:

http://msdn.microsoft.com/library/de...rp05162002.asp

Its C#, however it should be easily converted to VB.NET, post if you need
help.

One last item: The other major advantage of running the snippets
(EvalProvider.E val) in its own AddDomain is that you can "lock down"
(security wise/permission wise) that AppDomain so that the snippet cannot
do stuff its not suppose to. Depending on who is writing the snippets
this can be a good thing :-)

Hope this helps
Jay
"Joe Fallon" <jf******@nospa mtwcny.rr.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
I have some complex logic which is fairly simply to build up into a
string.
I needed a way to Eval this string and return a Boolean result.
This code works fine to achieve that goal.

My question is what happens to the dynamically created assembly when the
method is done running? Does GC take care of it?
Or is it stuck in RAM until the ASP.Net process is recycled?

This code executes pretty frequently (maybe 4 times per transaction) and
I
am concerned that I could be eating up RAM and not releasing it in my
ASP.Net application.
I would hate to have code like this bring down the web server just
because I
didn't clean it up correctly.

I took a quick look with Task Manager but when the code ran there was no
new
process created. Is that because it is running inside the ASP.Net
process?

I have seen a couple of posts that mention creating a separate appdomain
to
handle this type of issue.
Is there some complete sample code somewhere that shows how to do this
without accidentally re-loading the dynamic assembly into the ASP.Net
process?

Thanks in advance for any help.

--
Joe Fallon

=============== =============== =============== =============== =============== =
====
My web page calls the dynamic assembly code like this: where sbCode is
the
complex Boolean logic in String format.

Dim objEval As New EvalProvider
Dim objResult As Object = objEval.Eval(sb Code.ToString)

=============== =============== =============== =============== =============== =
====
Dynamic Assembly code:
=============== =============== =============== =============== =============== =
====
Imports Microsoft.Visua lBasic
Imports System
Imports System.Text
Imports System.CodeDom. Compiler
Imports System.Reflecti on
Imports System.IO

Namespace myNamespace

''' <summary>
''' Think about this: Your application does a lot of business logic,
some
of which requires complicated logical strings of code
''' that may change over time to meet certain business conditions or
metadata. Wouldn't it be great if you could pull the most
''' current string of code to be run out of your database based on
certain
stored procedure input parameters, and be sure it's run
''' and you get back the desired result? In fact, the returned string
of
code may even be dynamically created based on some of the
''' input parameters from the sproc itself.
''' </summary>
'''
''' <remarks>
''' http://www.eggheadcafe.com/articles/20030908.asp
''' </remarks>

Public Class EvalProvider

Public Function Eval(ByVal vbCode As String) As Object
Dim c As VBCodeProvider = New VBCodeProvider
Dim icc As ICodeCompiler = c.CreateCompile r()
Dim cp As CompilerParamet ers = New CompilerParamet ers

'Note: this list much match the list of Imports in the sb.Append
below!!
cp.ReferencedAs semblies.Add("s ystem.dll")
cp.ReferencedAs semblies.Add("s ystem.data.dll" )
cp.ReferencedAs semblies.Add("s ystem.xml.dll")

cp.CompilerOpti ons = "/t:library"
cp.GenerateInMe mory = True

Dim sb As StringBuilder = New StringBuilder(" ")
sb.Append("Impo rts System" & vbCrLf)
sb.Append("Impo rts System.Data" & vbCrLf)
sb.Append("Impo rts System.Xml" & vbCrLf)
sb.Append("Name space myNamespace " & vbCrLf)
sb.Append("Clas s myDynamicLib " & vbCrLf)
sb.Append("publ ic function EvalCode() as Object " & vbCrLf)
sb.Append(vbCod e & vbCrLf)
sb.Append("End Function " & vbCrLf)
sb.Append("End Class " & vbCrLf)
sb.Append("End Namespace" & vbCrLf)

'to debug your eval string uncomment this line
'Debug.WriteLin e(sb.ToString() )

Dim cr As CompilerResults = icc.CompileAsse mblyFromSource( cp,
sb.ToString())
Dim a As System.Reflecti on.Assembly = cr.CompiledAsse mbly
Dim o As Object
Dim mi As MethodInfo
o = a.CreateInstanc e("myNamespace. myDynamicLib ")
Dim t As Type = o.GetType()
mi = t.GetMethod("Ev alCode")
Dim s As Object
s = mi.Invoke(o, Nothing)
Return s

End Function

End Class

End Namespace
=============== =============== =============== =============== =============== =
====




Nov 21 '05 #6
Jay,
Thanks for the advice.
I have gone with Scott's solution and am very pleased with it.
--
Joe Fallon

"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:ua******** ******@TK2MSFTN GP15.phx.gbl...
Joe,
1. Do you know of any other way to Eval a String to get a Boolean result JavaScript as Scott shows in the microsoft.publi c.dotnet.framew ork.aspnet
newsgroup (not sure how this (languages.vb) newsgroup got left off that

half of this thread).

Alternatively you could use a computed column in a DataTable, if your data
is not already in a DataTable this may not work very well... The Expresssion syntax in the DataSet OM is closer to VB, then JavaScripts, however with
limits.

http://msdn.microsoft.com/library/de...ssiontopic.asp
2. Do you know if Eval will be a built-in function in ver 2.0 of the ..Net framework? Not that I know of
8. Since I am running in ASP.Net I would like to use the Cache to store
the

I have not looked at it a lot, there is the Caching Application Block

http://msdn.microsoft.com/library/de...chingblock.asp.
I normally simply keep the values in a Shared variables, however there is no getting ride of old one...

Hope this helps
Jay

"Joe Fallon" <jf******@nospa mtwcny.rr.com> wrote in message
news:eO******** ******@TK2MSFTN GP09.phx.gbl...
Jay,
Thanks for your input. You have helped me a lot in the past. I really
appreciate it.

0. BTW this dynamic assembly code only runs on a single page in a large
web site when a user enters a complex transaction. So I am not overly
concerned about it scaling (yet) since this will be a small percentage of the total hits on the site.

1. Do you know of any other way to Eval a String to get a Boolean result
other
than dynamically generating the assembly as shown below?

e.g. If I have a string such as "1=1" and I try to Cbool it I will get an error.
Cbool("1=1") - error!

But Cbool(1=1) will return True. (Note that this is not a string!)

So the all the dynamic assembly does is execute my string and return T/F.
This is the core of the dynamic code which is executed:
Dim boolResult As Boolean = Cbool((1=1))
Return boolResult
Notice how my original string is now represented as something that will
evaluate correctly.

So, if there is some other way to get the same result I would like to know about it.

FYI - I have some complex rules that become simple to code as a long
Boolean string which when evaluated returns T/F which is the only result I really need. When I tried coding these complex rules without building up a string it quickly got unmanageable. There was a huge advantage to building a string in the code. But now Evaling the string with a dynamic asembly
seems to be an issue.

2. Do you know if Eval will be a built-in function in ver 2.0 of the ..Net framework?

3. Good point about the Hashtable. If it stored both the string and the
result then it could act as a cache and dramatically reduce the dynamic
assembly creation by simply retrieving the result for each matching string that has been previously computed. I think there would be a large number
of matches since the rules would not change that frequently and so the
strings would tend to be repeated for each transaction type.

4. The hashtable resolves the point about compiling the same snippet 4
times and creating 4 identical asemblies.
The original idea was to create the dynamic assembly and just "throw it
away" when it Eval(uated) the snippet.
But as I read more about it I learned you can't unload an assembly and so I became concerned that I would be needlessly wasting memory. As I
understand it, ASP.Net monitors its AppDomain for "memory pressure" among other things and will tear it down and build a new one automatically. I
guess my dynamic asemblies would just cause it to do this more frequently. Agree?

5. Rick Strahl's article showed how to create a separate appdomain. I
downloaded his code and got it working within the current appdomain but it failed when trying to create a new one. Interestingly, he was working on
the exact same issue today and had MS Support on the line for 2 hours
until the figured out the problem. Sounds like the same problem I was
having with his code so I am hoping I can get it working tomorrow. This is a very tricky issue. Lots of people talk about it but Rick was the only
one who tried to abstract the problem and create a class that shows how to do it. MS should do this since they are the ones who know what works and
what doesn't. The documentation is a bit sketchy and without MS Support
help Rick wouldn't have solved it either since there were no errors
returned from the code.

6. Good point on the security of a separate AppDomain.

7. I was considering setting a variable (count of hashtable?) that would count the number of times I dynamically executed a snippet. When it
exceeded a certain threshhold I planned to tear down the separate
AppDomain and start over. Agree?

8. Since I am running in ASP.Net I would like to use the Cache to store
the hashtable. But the problem is the dynamic eval code is not in my code behind pages. It is in my Business Object tier and that does not know
anything about the ASP.Net Cache. Any recommendations on how to store this hashtable in my BO tier so that I will always have access to it?

Thanks!
--
Joe Fallon

"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Joe,
This code executes pretty frequently (maybe 4 times per transaction) and I
am concerned that I could be eating up RAM and not releasing it in my
ASP.Net application.
Concern! Are you creating a dynamic assembly 4 times per transaction?
Isn't that in itself causing a performance issue?

I would consider keeping a Hashtable matching code snippets (the vbCode
parameter) to the compiled Assembly. I would only create the compiled
assembly if it was not previous registered in my Hashtable. The caveat is you would need to ensure the code is thread safe...

My other concern is if you compile the same snippet 4 times you actually wind up with 4 "identical" yet individual compiled assemblies...

My question is what happens to the dynamically created assembly when the method is done running?
I would expect the assembly to remain in the current AppDomain until that AppDomain is unloaded, You might be able to handle the
AppDomain.Assem blyLoad & AppDomain.Domai nUnload events to monitor its
lifetime.

Notice there is no AppDomain.Assem blyUnload event, as you cannot unload
assemblies from an AppDomain without unloading the entire AppDomain.

Or is it stuck in RAM until the ASP.Net process is recycled?
Based on how other assemblies work with an AppDomain that is correct.
Is there some complete sample code somewhere that shows how to do this
without accidentally re-loading the dynamic assembly into the ASP.Net
process?
I don't have a specific link to a complete sample, however you should be able to create a "EvalProvid er" AppDomain, load & instantiate
"EvalProvid er" class & assembly in this second AppDomain, when you call
EvalProvider.Ev al it should run in this second AppDomain.

The following might get you started:

http://msdn.microsoft.com/library/de...rp05162002.asp
Its C#, however it should be easily converted to VB.NET, post if you need help.

One last item: The other major advantage of running the snippets
(EvalProvider.E val) in its own AddDomain is that you can "lock down"
(security wise/permission wise) that AppDomain so that the snippet cannot do stuff its not suppose to. Depending on who is writing the snippets
this can be a good thing :-)

Hope this helps
Jay
"Joe Fallon" <jf******@nospa mtwcny.rr.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
I have some complex logic which is fairly simply to build up into a
string.
I needed a way to Eval this string and return a Boolean result.
This code works fine to achieve that goal.

My question is what happens to the dynamically created assembly when the method is done running? Does GC take care of it?
Or is it stuck in RAM until the ASP.Net process is recycled?

This code executes pretty frequently (maybe 4 times per transaction) and I
am concerned that I could be eating up RAM and not releasing it in my
ASP.Net application.
I would hate to have code like this bring down the web server just
because I
didn't clean it up correctly.

I took a quick look with Task Manager but when the code ran there was no new
process created. Is that because it is running inside the ASP.Net
process?

I have seen a couple of posts that mention creating a separate appdomain to
handle this type of issue.
Is there some complete sample code somewhere that shows how to do this
without accidentally re-loading the dynamic assembly into the ASP.Net
process?

Thanks in advance for any help.

--
Joe Fallon

=============== =============== =============== =============== =============== = ====
My web page calls the dynamic assembly code like this: where sbCode is
the
complex Boolean logic in String format.

Dim objEval As New EvalProvider
Dim objResult As Object = objEval.Eval(sb Code.ToString)

=============== =============== =============== =============== =============== = ====
Dynamic Assembly code:
=============== =============== =============== =============== =============== = ====
Imports Microsoft.Visua lBasic
Imports System
Imports System.Text
Imports System.CodeDom. Compiler
Imports System.Reflecti on
Imports System.IO

Namespace myNamespace

''' <summary>
''' Think about this: Your application does a lot of business logic,
some
of which requires complicated logical strings of code
''' that may change over time to meet certain business conditions or
metadata. Wouldn't it be great if you could pull the most
''' current string of code to be run out of your database based on
certain
stored procedure input parameters, and be sure it's run
''' and you get back the desired result? In fact, the returned string
of
code may even be dynamically created based on some of the
''' input parameters from the sproc itself.
''' </summary>
'''
''' <remarks>
''' http://www.eggheadcafe.com/articles/20030908.asp
''' </remarks>

Public Class EvalProvider

Public Function Eval(ByVal vbCode As String) As Object
Dim c As VBCodeProvider = New VBCodeProvider
Dim icc As ICodeCompiler = c.CreateCompile r()
Dim cp As CompilerParamet ers = New CompilerParamet ers

'Note: this list much match the list of Imports in the sb.Append
below!!
cp.ReferencedAs semblies.Add("s ystem.dll")
cp.ReferencedAs semblies.Add("s ystem.data.dll" )
cp.ReferencedAs semblies.Add("s ystem.xml.dll")

cp.CompilerOpti ons = "/t:library"
cp.GenerateInMe mory = True

Dim sb As StringBuilder = New StringBuilder(" ")
sb.Append("Impo rts System" & vbCrLf)
sb.Append("Impo rts System.Data" & vbCrLf)
sb.Append("Impo rts System.Xml" & vbCrLf)
sb.Append("Name space myNamespace " & vbCrLf)
sb.Append("Clas s myDynamicLib " & vbCrLf)
sb.Append("publ ic function EvalCode() as Object " & vbCrLf)
sb.Append(vbCod e & vbCrLf)
sb.Append("End Function " & vbCrLf)
sb.Append("End Class " & vbCrLf)
sb.Append("End Namespace" & vbCrLf)

'to debug your eval string uncomment this line
'Debug.WriteLin e(sb.ToString() )

Dim cr As CompilerResults = icc.CompileAsse mblyFromSource( cp,
sb.ToString())
Dim a As System.Reflecti on.Assembly = cr.CompiledAsse mbly
Dim o As Object
Dim mi As MethodInfo
o = a.CreateInstanc e("myNamespace. myDynamicLib ")
Dim t As Type = o.GetType()
mi = t.GetMethod("Ev alCode")
Dim s As Object
s = mi.Invoke(o, Nothing)
Return s

End Function

End Class

End Namespace
=============== =============== =============== =============== =============== = ====




Nov 21 '05 #7

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

Similar topics

18
3162
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My question is what happens to the dynamically created assembly when the method is done running? Does GC take care of it? Or is it stuck in RAM until the ASP.Net process is recycled? This code executes pretty frequently (maybe 4 times per transaction) and...
0
1771
by: Brian Takita | last post by:
Hello, I'm getting the following error at the end of this message when trying to run the ReportManager and the ReportServer: Assembly system.data.dll security permission grant set is incompatible between appdomains. I had to apply KB 887787 (http://support.microsoft.com/?kbid=887787) to fix my previous error, which stated... Assembly microsoft.web.validatepathmodule.dll security permission grant
8
2021
by: George Meng | last post by:
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:
1
2570
by: billr | last post by:
hi there, I hope that someone will be able to shed some light on little old confused me. We are developing an application which will be deployed onto a Terminal Server machine. The application will be used concurrently by multiple users. We have a static object (which as you well know is only static per AppDomain), -I think I've just figured out the answer to my question, but perhaps some confirmation wouldn't go amiss-
8
1702
by: Fred Mertz | last post by:
I'm working towards an MCTS cert and I'm having to learn a bunch of stuff that I doubt I'd stumble across on my own. One such feature of .NET is AppDomains; programatically creating new AppDomains and programmatically loading/unloading assemblies in them. Question: What are some scenarios where I'd want to... 1 - programmatically create or destroy AppDomains 2 - load and unload assemblies in AppDomains?
3
3759
by: | last post by:
If this is simple, forgive my ignorance, but I'm coming from the CompactFramework where we don't use AppDomains. I did a fair bit of archive searching and couldn't find an answer and I got no responsed in the remoting group after a week, so I'm throwing a little wider net this time. I have a desktop app (FFx 2.0) developed with Studio 05 that loads assemblies in a separate AppDomains from the primary UI. I'd like to be able to hook up...
0
9404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10008
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8833
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5279
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3929
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.