简体   繁体   中英

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.

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.

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.

Tod,

Ran into the same issue and installed the netstandard library. It did solve the issues of the popup.

But let me rant, this is a new "solution" with a class compiled to a dll and a console application accessing the dll. All in .net 6.0 and yet I spend HOURS trying to debug simple setup bullshit in order to get their new libraries to work together. So fricking frustrating. At the end of the day I just want my code to run. Hell it was so much easier to write ASSEMBLER on the Mainframe than it is trying to shift to new .net releases. By now they should have a solid development environment with all of these issues solved. Apologies for the rant, but it is just FRUSTRATING.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM