Project Description
DBRef is a database-based referencing framework for .Net assemblies that is injected as demanded by the CLR.
What this means is that you can deploy all your DLLS to the database and have it injected into the application at runtime.
This has great potential for application deployment and updates!

The framework is designed to be as simple as possible and consists of two parts;
* a console application that can be used to register assembly references, which also integrates into Visual Studio projects as a post-build event
* a dll (DBRef..dll), which is referenced by the primary application and it provides dlls from the database, as needed.


Developed by: Shailen Sukul

Pre-requisites:
  • Microsoft .Net Framework 3.5
  • Sql Server 2005
  • Visual Studio 2008 (to edit source code)

ER.jpg
The database design consists of 3 tables:
  • Application - contains information about your application
  • Assembly - contains a serialized copy of assembly files (dlls)
  • Manifest - links the assemblies to an application for a particular release

Copy the DBref.dll and DBrefCommand.exe files to the bin/(Debug or Release) folder of your project (see the releases section)

In app.config of your main project, specify the assembly the manifest as follow:
// Place this in the header section
<configsections>
<section name="DBRefSection" type="DBRef.Configuration.DBRefSection, DBRef, Version=1.0.0.0, 
                         Culture=neutral, PublicKeyToken=null" allowLocation="true" allowDefinition="Everywhere" />
<configsections/> 


// Add a DBRef section
<DBRefSection ApplicationName="TestApplication" ReleaseVersion="1.0.0.0" DatabaseConnection="DBRefDB">
<Assemblies>
        <Assembly Name="SampleAssembly" Filepath="..\..\Reference\SampleAssembly.dll" 
                                             Description="Sample Assembly 1" />
       <Assembly Name="SampleAssembly2" Filepath="..\..\Reference\SampleAssembly2.dll" 
                                             Description="Sample Assembly 2" /> </Assemblies>
</DBRefSection>


// provide a database connection string
<connectionstrings> <add name="DBRefDB" 
                       connectionString="Server=...;Database=DBREF;Trusted_Connection=yes;"/> 
</connectionstrings> 



Run the Database.sql file to create the tables in your target database. Alternatively, simply run the post-build event below and the configured database will get created automatically (assuming you have database creation rights).

Add a post-build step to your project to copy the assemblies to the database.
postbuildstep.jpg

Add one line of code to the program.cs file of your application to intialize DBRef.
DBRef.Utility util = new DBRef.Utility();

CodeInjection.jpg

That's it!
Now you can delete all your referenced dlls from the bin folder and it should load from the database when the application executes.


Enjoy and please update the discussions section with your feedback!

Last edited Aug 29, 2009 at 4:04 AM by shailensukul, version 24