0

The exe calls into the dll, but does not explicitly use the interface that was removed. Why can't an EXE compiled with old DLL be run at runtime with new DLL?

The compiler must be keeping extra information about types and not simply what is used.

EXE

void main()
{
    new Foo().PrintHello();
}

Old DLL:

public class Foo : IOldInterface
{
   public void PrintHello()
   {
        Console.WriteLine("Hello");
   }
   public int Something { get { return 123; } }
}

public interface IOldInterface
{
   int Something { get; }
}

New DLL

public class Foo
{
   public void PrintHello()
   {
        Console.WriteLine("Hello");
   }
}
2
  • I can't reproduce the problem with the code you've provided - but the fact that I had to change it even to get it to compile suggests you probably haven't tested with this code either. Please provide a minimal reproducible example which actually demonstrates the problem.
    – Jon Skeet
    Jan 10, 2017 at 19:00
  • Sorry about that. You're right. I was extrapolating from a much larger code base and didn't compile this. Updated post before effectively abandoning this issue.
    – aitee
    Jan 10, 2017 at 23:18

1 Answer 1

0

Short of the matter is that simply removing an interface off a type doesn't make it incompatible with another library using it (as long as the method prototype isn't changed, as well as these reasons: https://stackoverflow.com/a/806510/578879)

I had thought that this couldn't be the issue but posed the question without doing this simple test myself. The issue in my larger project most likely be due to a build issue (somehow having an older version of the exe that actually referenced IOldInterface directly -- hence the IOldInterface not found exception).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.