Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS dll reference error - Instance object was created as immutable

If you try to add a NetStandard library dll to a .net core application Visual Studio throws the error:

instance object was created as immutable

And refuses to add the reference.

like image 809
Tod Avatar asked Aug 27 '26 13:08

Tod


2 Answers

I thought I would share this as nothing much turns up in a search. You need to add a reference to the NetStandard.Library NuGet Package, before you can add a .netstandard library.

https://www.nuget.org/packages/NETStandard.Library

Then add references to the DLL.

As a side note, I never had any issues adding a project reference to a netstandard 2.0 project, but to its output dll - I did.

like image 91
Tod Avatar answered Aug 30 '26 03:08

Tod


I had this issue when trying to add a reference to the TwinCat.ADS library. My issue turned out to be the opposite of yours. I had added the package using NuGet. NuGet didn't install the package correctly but was preventing me from adding the reference to the dependencies separately. I had to remove the package from NuGet before I could add the library to the references.

like image 26
user19370793 Avatar answered Aug 30 '26 02:08

user19370793