Problem
I have the below code in the two respective dlls. dll1 depends on dll2.
When DoWork()
is called it will execute myInterface.MyListMethod(ImmutableList<byte>.Empty);
fine. When it goes to execute myInterface.MyArrayMethod(ImmutableArray<byte>.Empty);
the following exception is thrown:
Exception:System.MissingMethodException: Method not found: Namespace.MyArrayMethod(System.Collections.Immutable.ImmutableArray'1<Byte>)
dll1.dll
public class TestClass
{
public void DoWork()
{
IMyInterface myInterface = new MyInterface();
myInterface.MyListMethod(ImmutableList<byte>.Empty);
myInterface.MyArrayMethod(ImmutableArray<byte>.Empty);
}
}
dll2.dll
public class MyInterface : IMyInterface
{
public void MyArrayMethod(ImmutableArray<byte> byteArray)
{
// Do stuff
}
public void MyListMethod(ImmutableList<byte> byteList)
{
// Do stuff
}
}
public interface IMyInterface
{
void MyArrayMethod(ImmutableArray<byte> byteArray);
void MyListMethod(ImmutableList<byte> byteList);
}
Testing
From my point of view it seems that ImmutableArray<>
is at fault as I've tried this with multiple types, including as you can see above, with other types in the Immutable namespace. It only happens with ImmutableArray<>
as far as I've tried.
I've also made sure that both the dlls are the current dlls and there isn't some old cached version hanging around the gac. Updating the Interface to have another method then calling that before MyArrayMethod works as expected.
Visual Studios specifically doesn't pick up calling references to the method on the interface that contains the ImmutableArray<>
param but it will for methods with the ImmutableList<>
. It will also pick up references if you remove the ImmutableArray<>
param from the method.
The solution builds fine however, it's only when it tries to JIT at run-time that this error is thrown.