VS dll reference error - Instance object was created as immutable
Asked Answered
S

2

6

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.

Subtenant answered 7/7, 2022 at 13:31 Comment(1)
Hi Tod, glad to know you've found the solution to resolve this issue! Please consider accepting it as an answer to change its status to Answered. It will also help others to solve a similar issue. See can I answer my own question.., Just a reminder :)Footstool
S
13

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.

Subtenant answered 7/7, 2022 at 13:31 Comment(1)
It was a few hours of head scratching, that's to be sure. With several emails bothering a 3rd Party dev for "the right dll" I realised it was just affecting net standard 2.0 DLLs. Then a shot in the dark found the Nuget package.Subtenant
R
4

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.

Repletion answered 12/7, 2022 at 3:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.