Detecting assembly changes

C

Chris Dunaway

I'm writing an app that processes orders for various customers. For
most customers, the processing is the same. However, a few customers
require custom processing in addition to the standard processing that
is performed on all orders.

To accomplish this, I have created an interface and for the sake of
this question, it's only method is called SpecialProcess. For each
customer that requires special processing, I create a separate assembly
with a class that implements this interface. Then, during the
execution of the app, I check an .xml file to see if the particular
customer requires special processing and if so, I load the assembly for
that customer using reflection and execute the SpecialProcess method.

The application is implemented as a Windows service so it constantly
runs. My question concerns updating an assembly that may already be
loaded. I do not want to stop and restart the service if the custom
processing assembly requires changes. If an assembly is loaded again
but it is a different version, what would happen to the original loaded
assembly?

For example, say the application loads "Custom.dll, v 1.0" during it's
execution loop. Then say, that before the next time it needs to call
the custom.dll, it has been changed to version 1.1. When the code
that loads the assembly is executed, will both versions be in memory?
Or will the new version replace the older version? Will the .Net
runtime handle this for me properly?

I hope my question is clear. I know that I can use another AppDomain
to load the assembly and then unload the AppDomain to unload the
assembly, but is that the best way?

I merely need to be able to update an assembly without having to
restart the app that uses it.

Thanks,

Chris
 
C

Chris Dunaway

Thanks for the link. It is very interesting, but not what I was
looking for. Basically my Windows service starts and then does some
processing each time a timer interval fires. In this processing is
code like this (pseudocode):

'This sub executed periodically in a timer event.
Public Sub Process()
GetCustomerData
PerformStandardProcessing
If SpecialProcessingNeededForThisCustomer Then
LoadCustomAssemblyForThisCustomer
ExecuteCodeInCustomAssembly
End If
End Sub

If, between the first and the next execution of the custom assembly
code, the assembly is replaced with an updated version, will it load
the new assembly and still keep the old loaded in memory? Or will the
new assembly replace the old one in memory?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top