Cast Works Only When Method Called From Entry Assembly?

So I have some code (.Net Core 2.1), something like this:

scope.ServiceProvider.GetService(someType) as ISomething<T>

That is within a method that is part of Assembly A.

Here’s the weird part. If the enclosing method is called from my unit test (Assembly B) – the cast works.

If the method is called from the same Assembly (Assembly A) – the cast fails. No idea why. When debugging everything looks the same in both cases.

Help?

submitted by /u/jamesmh_
[link] [comments]

Leave a Reply