sooprise
sooprise

Reputation: 23177

Running Two Of The Same DLL's In The Same RunTime?

The problem: I have dev code and production code in DLL form and I want to be able to compare the results from each. This all needs to occur in the same run time.

What I'm looking for: Code that simply loads the dev DLL, stores the results, then opens the prod dll, stores the results, then compares the results from both.

Current Strategy: I'm thinking of using app domain right now, but I haven't been able to find any very clear code examples that simply show how to load a DLL, run a method from that DLL, and store the results from that DLL. The concept of app domains is still fuzzy to me as it seems very external to the code it's being called from so storing results from this sort of external app domain is a bit confusing for me.

In any case, I'd really be interested in a simple example demonstrating loading a DLL and running code from it, storing the results, and loading another version of the same DLL and doing the same thing.

Any help would be super appreciated! Thanks!

Upvotes: 2

Views: 729

Answers (1)

Abe Miessler
Abe Miessler

Reputation: 85036

I would recommend giving this article a read. Their example uses extern alias to specify two different versions of the same DLL.

Create the aliases above your using section:

extern alias oldVer;
extern alias newVer;
using System;
.
.
.

Add your references and give each one the appropriate alias. You can specify what aliases to use with the Reference in it's properties:

enter image description here

Once you have the aliases in place you can do something like:

Console.WriteLine(oldVer::MyLibrary.MyClass.method());

Console.WriteLine(newVer::MyLibrary.MyClass.method());

Upvotes: 7

Related Questions