Mscorlib issue?

I’m hacking away at my project here, now using the demo solution for the portal to build my water system interface. So I am modifying the demo solution to suit my needs. In doing so, the code seems to looking in 2 places for things like “Font”, “Bitmap”, “Color”, drawing stuff. One of the errors:

“The type ‘Font’ exists in both ‘GHIElectronics.TinyCLR.Drawing, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null’ and ‘System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’|Demos|C:\Users\jscma\TinyCLR_Samples\Third Version\TinyCLR-Samples-master (2)\TinyCLR-Samples-master\Official Demos\FEZ Portal\Windows\Buzzer.cs|21|Active|”

is this a multiple mscorlib thing going on here? I have “using system.drawing”, and the tinyclr core nuget is installed.

No issue.

Clean up you project, delete all nuget in folder packages.
And you may need to uninstall and reinsall every single nuget.

@mcalsyn has many threads about this, I think.

I tried, did what martin said to do, deleted all of the nugets (20 of them?), closed VS down, deleted everything in /packages and /bin and /obj, restarted, took an hour to reinstall all of the nugets, then inserting all of the “using’s” for all 15 or so windows, ran code cleanup 4-5 times, now I’m down(?) to 200 or so errors. Buried in the errors are still the things like which file does “Font”, “Color”, “Bitmap” refer to, back to where I was in the beginning. Abandoning this project, it’s easier to just start again, but I’ve done this twice so far… It was running fine until I added a .cs class file under the “Windows” folder - in fact my version before everything went south is still running nice on the portal … I am assuming that mscorlib versions are still conflicting somewhere…

try deleting the reference to system.drawing.

Didn’t help…

I started again with the demo program, still getting errors but not as many - mscorlib conflicts wit the usb and sd codes, so I just deleted the two windows that use that code. Fixed a couple of resource calls that weren’t difficult to figure out, I think the demo program is a a bit out of date… Finally no errors. Built the ap and while downloading to the portal, I get an error “failed to allocate 12 blocks…” something like that, visual studio then crashes a second later.

I will reinstall VS 2019 again and see how that goes.

Reinstalling VS doesn’t help on this case. What demo were you trying so we can take a look?

Also, enable extend heap if it is available on your board to see. Your “hack project” may use a lot of memory.

This is what I get when I load the portal demo program on a fresh reinstall of VS2019. mscorlib seems to want to lurk around 3 windows - sd.cs, usb.cs, and basictestwindow.cs.

It runs fine with VS2017, so I will continue there.

Ok I noticed that I had another copy of 2019 running in the background when I opened the demo program in 2019, so I closed all instances of visual studio, and opened the demo sln in 2019 and it opened without errors.

Dat, I am running the portal official demo under ‘samples’ on gitub, it’s called demos.sln. I am hoping to use that as a starting point for my project. Lets see how far I get this time…

In addition to packages/, bin/, and obj/, don’t forget that intellisense may hide another copy of mscorlib in your .vs/ directory. The .vs directory is a child of your solution directory and may be marked ‘hidden’.

And FWIW, I looked into how to solve this in a durable fashion by fixing various msbuild scripts, but it turned out to be a much bigger task than I expected. It might be fixable by changing the TinyCLR build files into the new Sdk package format. It’s like a hole in the roof - I don’t think about it when it is not raining, and when it’s raining, I just grab a bucket because I don’t have time to do the proper fix.

Thanks Martin, this is really useful! I went looking for that .vs directory and couldn’t find it, explorer search turned up lots of vs type stuff but not the .vs directory of interest. So now I know where to look if the error shows up again. For this project, deleting and rebuilding all of the nuggets is a major piece of work lol! And I suspect that the mscorlib issue was causing the block allocation error with vs crashing….