Alois Kraus

blog

  Home  |   Contact  |   Syndication    |   Login
  133 Posts | 8 Stories | 368 Comments | 162 Trackbacks

News



Article Categories

Archives

Post Categories

Image Galleries

Programming

It has been some time since my last post. But I have an excuse: I did work on an improved version of the graphical EntlibConfig tool. The code can
be downloaded from the Sample Section of Gotdotnet. When you install the Jan 2006 of EntLib all works fine as long as EntLib is the only project in your bin folder. But for real Enterprise scenarios this is not true. The bin folder of your project is crowded soon with all sorts of other dlls and executables. Some might be managed some not, others might even require special permissions (Interop.WindowsInstaller.dll which will throw during assembly load an SecurityException). These problems can cause a significant startup delay or break the tool completely. The config tool itself is decoupled all application blocks and loads them via the Dependency Injection Pattern another good source of information about this pattern can be found at the web site of the Spring.NET framework. This loose coupling is nice from the architectural point of view but can get in your way when you want to start the tool. Since there are no references to other projects tool does load the rest of the GUI via the following mechanism:

  1.     Load all assemblies in deployment directory of EntlibConfig.exe.
  2.     Check each assembly for the ConfigurationDesignManagerAttribute and plug it into the UI hierarchy.

This approach does introduce some problems:

  •     Increased startup time.
  •     Loading unmanaged Dlls or some Interop assemblies which break the tool completely.
  •     Unable to load App.config which references other EntLib extensions which are not located in the folder where the tool resides.

I have tried to circumvent these issues by making it configurable what (Design) assemblies are loaded at startup and where to look for missing references. If you load e.g. the Logging QuickStart sample App.config into the tool it will show you the following error:


   
With my extension you will see instead the Assembly Loader configuration dialog which does let you add the missing dependency at run time without the need to restart the tool.



To add the missing dependency you have two options:

    a) Add the assembly in question to the ones which are loaded during startup.
    b) Add an assembly resolve folder where to look also when resolving missing dependencies.



I would recommend to use option b) for assemblies which do not contain any design time (*.Design.dll) parts for the UI itself. This way you can load all UI extenstion at startup from any folder you would want. To enable XCopy deployment I made all selected paths/files relative to the Appdomain directory of the EntLib tool. After clicking OK the new settings are saved in your User profile (NOT EntlibConfig.exe.config) and the assembly bind is tried again. You should now see the UI without any further investigation what dependency might be missing. To make things complete you can fire up this dialog via the File Menu of the EntlibConfig tool


The integration of the Enterprise Library and its config tool into a real Source Control System (no not Visual Source Safe) is much easier now. I have delivered a default configuration in the Enterprise Library App.Config file which explains the blue items in the dialogs. You can still change the assembly resolve directories and loaded assemblies at startup since the configuration is stored in the current users profile. With this twofold approach you can deliver presets which cannot be changed and give at the same time the user (developer) the freedom to add the needed dependencies on the fly without the need to check out the EntlibConfig.exe.config file from the source control system.

Lessons learned

During the development of this Addon I have found that it makes perfect sense to use Visual Source Safe on a Single User Machine. I had to review my changes compared to the "official" Enterprise Library which is with a Source Control system much easier. As always during development unexpected things happen which make you wonder why your application behaves so strange.

Problems/Bugs found:
  • When you add a settings collection with an auto generated settings class I receive in the Appdomain.CurrentDomain.AssemblyResolve event handler the request for a not existing "System.XmlSerializers" assembly. This might have sth. to do with the on the fly generated assemblies by XmlSerializer but I do not understand why I should know about this. In the handler I  had to alter my application logic to skip this not existing assembly. If you consider this a bug you can vote here.
  • After showing the Open File Dialog the current working directory is changed which did cause my relative path expansion algorithm blow up. There is a settings OpenFileDialog.RestoreDirectory which you can set to true to get the desired behavior. I found it out after filing a request at the Product Feedback Center. It would be nice to document this in the Path.GetFullPath function documentation. It is not easy to understand why the application behaves differently after the File Open Dialog.
I hope this gives you better understanding what problems you are faced with when you deploy a software package which contains third party software or what constraints you have when you want to enable software to run as checked in version in a source control system.
posted on Sunday, March 5, 2006 10:45 PM

Feedback

# Some bloody cool Enterprise Library v2 Extensions 3/23/2006 9:01 AM Tom Hollander's blog
Sorry I'm a bit late to the party here - but better late than never! There are a couple of really cool...

# re: Extend the Enterprise Library Config Tool - A Configurable Assembly Loader 4/3/2008 2:35 PM Sylvain Dorion
Hi Alois,

is there a site where we can still download your program ?

GotDotNet seems to be closed by now and I can't find your project on MSDN...

thanks,

Sylvain.

# re: Extend the Enterprise Library Config Tool - A Configurable Assembly Loader 4/6/2008 7:06 PM Alois Kraus
Hi Sylvain,

sorry there is currently no place to download the project again. Enterrprise Library 4 is coming soon which should improve things. If not I will consider to put it up again.

Yours,
Alois Kraus

Post A Comment
Title:
Name:
Email:
Comment:
Verification: