Monogame Project cannot resolve Microsoft.-

In Rider Ive downloaded all of the monogame templates and the dotnet framework, but upon opening the cross platform template, there are errors strewn across the code. Im assuming this is because Rider is somehow doesn't have or doesn't recognize the botnet framework. At the beginning of the standard "Game1" file, "Microsoft" cannot be resolved, which I assume cascades into all of the methods in the code.

Ive uninstalled and reinstalled the dotnet framework, and have tried importing other packages through NuGet with not avail.

Help!

0
3 comments

Hello Dominik,

Thank you for contacting Rider support. As I can see MonoGame 3.8 project templates targets .Net Core 3.1 out of the box, but not .Net Framework.
I see the following options for possible solution:
1. To use .Net Core instead of .Net Framework:
  • Install .Net Core 3.1 from here or .Net 5 as it is supported in MonoGame;
  • Ensure `File | Settings | Build, Execution, Deployment | Toolset and Build | .Net CLI executable path` is set to dotnet with /sdk/3.1{minor} or /sdk/5.0{minor} in there;
  • Ensure .Net Core 3.1 or .Net 5 is set as a target framework for your project. (`Right click on project in Solution Explorer | Properties | Target framework`)
2. To use .Net Framework:
  • Set the proper .Net Framework in project properties. (Might be amended in .csproj file directly or via UI (`Right click on project in Solution Explorer | Properties | Target framework | ... | select the .Net Framework you have installed`)
The following steps worked for me: (this Getting Started guide helped me)
  • I have .Net 5.0 installed on machine (it is backward compatible with 3.1);
  • I have Visual Studio with .Net Framework and .NET SDK installed;
  • In File | Settings | Build, Execution, Deployment | Toolset and Build for .Net CLI executable path I have path to the dotnet executable with /sdk/5.0{minor}; MSBuild version is set to MSBuild.exe from Visual Studio folder.
  • I installed Monogame templates via CLI: `dotnet new --install MonoGame.Templates.CSharp`;
  • I installed Mgcb editor via CLI: `dotnet tool install --global dotnet-mgcb-editor`;
  • I registered Mgcb editor via CLI: `mgcb-editor --register`;
  • Open Rider | New solution | there are new project templates on the bottom in `Other` section | MonoGame Cross-Platform Desktop Application
  • I am able to build/run the project created. I am also able to retarget the project to .Net Framework via the ways I described above.
Hope it helps. Please let me know if still you encounter issues. 
0

Hello Dmitry,

Thank you for your reply. All the errors are now gone, here's what I did.

I changed the .NET SDK to 5, which didn't work until I changed the C# version to 8.0 instead of it's default. 

However, I now have only one more issue which is that it spews out an "Error building Win32 resources -- Unable to read beyond the end of the stream." I have absolutely no idea what could be going wrong, since its still just the default code that is there.

Thank you again!
Dom

EDIT: I just found a lot of errors in the app.manifest file, "URI is not registered" How can this be fixed? 

0

Hello Dominik,

Apologies for not responding earlier.
Would you mind trying to create a project via the `dotnet new mgdesktopgl` command and check if the issue persists?

Please let me know if it doesn't help.

0

Please sign in to leave a comment.