.Net 5 lost references.

SilverShaded

Well-known member
Joined
Mar 7, 2020
Messages
93
Programming Experience
10+
Im having problems with .Net 5. I upgraded my solution using the upgrade-assistant tool. Long story short many of the project references simply dont work anymore, so the error list is up in the thousands as objects created in other projects (which are part of the solution) are no longer recognised. Any ideas?
 
Solution
A bit more perseverance and it now seems to work properly in .Net5 and in .Net6 Preview. Only thing i can suggest is don't bother with Upgrade-assistant and re-create the projects manually.
That tool is still in preview so it's bound to have some issues. I've never used it so I'm not sure what it should do, does do and doesn't do but references work a bit differently in .NET Core. You generally don't reference assemblies installed in the GAC but, rather, install NuGet packages. You can simply remove the problematic references manually and then add the appropriate NuGet packages yourself. The documentation will tell you what package is required for each type you're using.

If you're talking about third-party references then you will definitely need to remove them and add a .NET Core compliant assembly reference. If one is not available then you are out of luck. Ask the author to provide one and stick to .NET Framework until it's available, or find an alternative library.
 
Hi thanks for the reply. The references are actually to stuff i’ve written, just in seperate projects but included in the same solution.
 
Check that these projects are upgraded or compatible with .Net 5 also, and that they are included in project references.
 
Yes, theyre all upgraded. I have seen a similar issue before with different versions of .net 4 being used but this time they are all v5. I’ll have have another look later today and maybe try a few things to see if it works with complety new solutions/projects.
 
Are those other projects truly referenced from your current solution, as in your current solution has nodes for those other projects? Or are you referencing those other projects by simply pointing to the compiled assemblies in their original directories, or copying the compiled assemblies into some location (perhaps your projects bin directory) and then pointing to the compiled assembly there?
 
They are all in the solution and referenced as such. Tried automatically referencing them from the menu as well.

if i open a relevent file from the referenced project the errors dissapear, only to re-appear when building the solution.
 
Ok, made some prgress, upgrade-assistant puts a load of files int he main project that simply shouldnt be there, once removed most of the errors were resolved. Also some projects were targeting net5.0 and changing them to net5.0-windows solved another problem. So im down to three errors which are driving me nuts. Basically i cant open any forms witht the error 'Value cannot be null. ("Paremeter 'Property name')'.
 
Last edited:
It did build an run once, but now i just get different random build errors every time i build. Configuration/path issue maybe? I got bored of it for today.
 
Only time I've heard of that is you use the WinForms Designer and there is some kind of circular dependency among the various assemblies used by the custom controls. That was back from years ago when I abandoned using the WinForms Designer and just opted to hand code my WinForms. I don't know if something similar maybe in play with the case of your migrated/upgraded solution.
 
Well i think i give up, ill stick to 4.8. I tried re-creating all the projects from scratch and just dragged over the .cs files, it did fix one issue in that i was then able to open the Forms & dialogs ok. but i still get a load of errors due to it complaining about not finding references which are clearly there. Ok i must be doing something wrong but for the moment its simply not worth the hassle, ill try again in a year or two when it might have been fixed or a new version of visual studio is out.
 
Last edited:
Ok i didn't give up and finally got it all working. There was a number of duplicated files and files copied in the wrong places etc. presumably put there by the Upgrade-assistant. So in the end i basically re-created the projects, transferred the .cs, .resx etc files over, this enable my forms to open properly, deleted and moved around the excess files etc and eventually got it working. Had to find the v5 version of the windows.forms.datavisualisation stuff.

The good news is it definateley seems to be running faster which was partly my interest in upgrading (apart from the fact its just new and i wanted to try it).
 
I think that it's fair to say that that Upgrade Assistant isn't ready for prime time. It is clearly indicated that it's in preview though, so that's no great surprise. I suspect that they may be looking to release it officially with .NET 6.0.
 
Well, it worked in debug mode, i switched to release mode, stopped working, switched back to debug mode, stopped working. The whole thing seems somewhat flaky. It doesnt seem to like multiple projects in one solution at all.
 
Back
Top Bottom