The problem I am having is that I need to reference a dll this is rebuilt every hour and are placed into a unique directory. So every couple hours I have to go to the newest directory and reference that dll for mt project.

What I did so far is created a script that can find the most recent dll in the right directory using the pre-build event. The only problem is I cannot figure out how to reference the dlls in the pre-build event.

Does anyone got any ideas?

I am using visual studio and i am making a windows form app.

8 Years
Discussion Span
Last Post by BhuvanRam

You can use reflection to load an assembly at runtime.

Consider this code compiled into Foo.dll

namespace Foo
    public class Bar
        public string Blah()
            return "Blah";

And then in another program

using System;
using System.Reflection;

class Program
    static void Main(string[] args)
        Assembly assembly = Assembly.LoadFile(@"C:\Users\Anthony\Documents\Visual Studio 2008\Projects\Foo\Foo\bin\Release\Foo.dll");

        object o = assembly.CreateInstance("Foo.Bar");

        Type type = o.GetType();
        MethodInfo methodInfo = type.GetMethod("Blah");

        string output = (string)methodInfo.Invoke(o, null);


Edited by apegram: n/a


You can pass through Constructor, Or Take a look at invoking delegate function.


You can do one more thing Go to Visual Studio Properties --> Build Events --> In a Post Build Event --> Type like this copy "Your Source Location" "Destination Location",. Thats it. Visual studio will take care the rest of the things. i.e., it will copy the DLL From Source Location to Destination Location on every new Build

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.