views:

223

answers:

3

I have an application that uses many different .NET managed DLL's as objects (each DLL implements a common interface). Each DLL also has a version number in the file name.

Suppose I create the object "Shape~01.dll." The application will use that DLL but it can't be replaced while the application is running. So, if I want to "upgrade" the shape dll I have to create "Shape~02.dll" and the application has to dynamically search for and load the newest dll everytime a shape is created and/or the user has to restart the application. It get's worse, each dll depends on the main .exe thus has to be rebuilt with the main .exe.

Is there an easier method to have dynamically "replaceable" objects?

A: 

Well, this isn't the best solution (still thinking about it), but you can unload dll files which will allow them to be replaced. That might be a quick stopgap solution until you come up with a better idea.

mos
A: 

You don't mention which language/platform you are trying to accomplish this in, so I will answer for the .NET Framework.

If you want to do it the hard way look at Shadow Assemblies, this is the method that ASP.NET uses to keep the site updateable though it is using the files.

For a much easier method look at the new System.Addin namespace, this uses Shadow Assemblies under the hood and should do what you want.

joshperry
A: 

Instead of polling when creating an object, why not just request notification from the system when the file system changes?

The class is System.IO.FileSystemWatcher in.NET.

For native code there are a few ways to watch a folder, but IANAND (I am not a native developer ;).

Although having said those things, you probably want to rethink the reason you need to change your objects so frequently, because it will probably take a lot of work to make it work.

You used the dynamic tag, so maybe you should try a dynamic language? :)

Fowl