2

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!

Abe Miessler
  • 82,532
  • 99
  • 305
  • 486
sooprise
  • 22,657
  • 67
  • 188
  • 276
  • How are you comparing the results? If it can be converted to text format, couldn't you just write it to a file and compare the files? – Davy8 Mar 14 '11 at 22:39
  • possible duplicate of [Referencing different versions of the same assembly](http://stackoverflow.com/questions/223195/referencing-different-versions-of-the-same-assembly) – NotMe Mar 14 '11 at 22:41
  • 1
    Also: see http://blogs.msdn.com/b/abhinaba/archive/2005/11/30/498278.aspx – NotMe Mar 14 '11 at 22:42
  • 2
    @Chris having read through both questions I don't think that is a suitable duplicate. – Justin Mar 14 '11 at 22:56
  • @Kragen: Considering the question is about how to reference different versions of the same assembly.. and the top answer to the linked question references an article about using extern alias.. I think there isn't much divergence here. The only real difference between the two is that this OP wants to store some results, which is secondary to his problem of loading the assemblies. – NotMe Mar 15 '11 at 14:21

1 Answers1

7

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());
Abe Miessler
  • 82,532
  • 99
  • 305
  • 486
  • I followed your steps, built a bunch of code, then ran it and I got the following error: The external alias 'MyAlias' was not specified in thee /reference option. Any ideas? Thanks! – sooprise Mar 15 '11 at 15:06
  • If you go to compile options under your project properties you should be able to specify the alias names there, which I think will solve that error. – Abe Miessler Mar 15 '11 at 19:08