tags:

views:

150

answers:

2

I am working with .Net 2.0 ASP.NET Web Application.

I am programmaticaly creating an assembly containing namespace and classes specified within xml file in the web application. I have created a separate library that does that, I get the assembly and that's fine.

But I don't want to reference this as a precompiled component.

I want to create it on the fly, so when I run the build of the web application, the assembly is built, the reference to the assembly added and then the web application code can use it further. Plus, I can have the intellisense.

Now this is exactly the scenario for the build providers, but the problem is that the build providers don't work with this type of application.

I have managed to run the assembly generation tool like so:

<Target Name="BeforeBuild">
  <Exec Command="CreateAssembly.exe config.xml"/>
</Target>

But no luck with dinamically referencing the generated assembly.

I'm stuck, any ideas? Thanks.

+1  A: 

The class you are looking for is the Assembly class within the System.Reflection namespace.

Example

Assembly.Load(AssemblyPath)

or

Assembly.LoadFrom(AssemblyPath)

These methods can be used to load a non-referenced assembly into your app-domain.

There are various conditions and restrictions so I would read up on them both.

Links

Assembly.Load (MSDN)

Assembly.LoadFrom (MSDN)

Useful MS KB Article

Have fun!

Charlie
Charles, thanks, I'm aware of the System.Reflection, but I'm looking for a way to reference it within build process.
Bokka
A: 

I've been toying around with using Rake for automating builds recently so you might want to give that a try. Here's a couple of links that you might find useful:

Ian Oxley
Thanks Ian, seems really interesting - nice syntax for a build runner. :) I'll look if it could provide the means for my needs.
Bokka