The purpose of this post is to discuss on a topic that I find rather abstract. There will be no reproductible example, unfortunately, but I am curious if there is anyone here who encountered this previously, as well as some tips on what could be going on. Hopefully the things stated below will be enough for you to make an overall idea.
While writing some unit tests, I noticed something that's going on and makes the tests fail. When debbuging I noticed that an object, Properties
, is basically null due to having "Could not evaluate expression"
when hovering the mouse over it. This causes the program to consider it a null, thus making the tests fail.
I took into considerations all possible causes code-wise, then I thought it might be a problem with Visual Studio's debugging settings, only to find out that it's because of an assembly which that object was imported from.
This assembly is loaded into the project like this:
<Reference Include="Connectivity.DataModel, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\..\_external\nuget\nes\Connectivity.DataModel.1.0.0\lib\netstandard2.0\Connectivity.DataModel.dll</HintPath>
</Reference>
I noticed that in another project, the Connectivity.DataModel.dll
is referenced as a NuGet and not as an assembly. Therefore, I changed the code above to this:
<ItemGroup>
<PackageReference Include="Connectivity.DataModel" Version="1.0.0" />
</ItemGroup>
Which finally made the object Properties
work as intended.
What is weird only comes now - so after replacing the first code with the second, I ran the application, made sure the tests pass and then decided to undo this change, as, in theory, it should have worked anyways. After reverting back to how it was referenced previously, I was surprised to find out that it STILL works - basically what previously would prompt me that "Could not evaluate expression"
error message, now worked.
What could be going on? Why would it work after referencing it as a NuGet and running the code once? The weirdest part now is that I am not able to replicate the issue without getting a brand new copy of this project off git.
Thank you in advance for any piece of advice!