Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

Stardew Valley--SMAPI tutorial mod failed to load because 'its DLL has no 'Mod' subclass

$
0
0

I am following this tutorial from the Stardew Valley wiki on creating your first mod with SMAPI. Sorry I feel like I included a lot of info but I see people asking for more in the comments a lot so I thought better safe than sorry? Thanks :)

After following the tutorial and running the game through Steam with SMAPI, I got the following warning:These mods could not be added to your game.

  • SalsFirstMod 1.0.0 because its DLL has no 'Mod' subclass.**

I am using:

Visual Studio 2022Windows 11 HomeSMAPI 4.08,Stardew Valley 1.6.8,.NET 6.0

The full output from SMAPI:Full SMAPI output

The build output:

1>------ Build started: Project: SalsFirstMod, Configuration: Debug Any CPU ------  Restored C:\src\SalsFirstMod\SalsFirstMod\SalsFirstMod.vbproj (in 889 ms).  1>SalsFirstMod -> C:\src\SalsFirstMod\SalsFirstMod\bin\Debug\net6.0\SalsFirstMod.dll  1>[mod build package] Handling build with options BundleExtraAssemblies: null, EnableModDeploy: true, EnableModZip: true, GameModsDir: 'C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Mods', IgnoreModFilePaths: null, ModDllName: 'SalsFirstMod', ModFolderName: 'SalsFirstMod', ModZipPath: 'C:\src\SalsFirstMod\SalsFirstMod\bin\Debug\net6.0', ProjectDir: 'C:\src\SalsFirstMod\SalsFirstMod', TargetDir: 'C:\src\SalsFirstMod\SalsFirstMod\bin\Debug\net6.0'1>[mod build package] Copying the mod files to C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Mods\SalsFirstMod...  1>[mod build package] Generating the release zip at C:\src\SalsFirstMod\SalsFirstMod\bin\Debug\net6.0\SalsFirstMod 1.0.0.zip...  ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

My code:ModEntry.cs

using System;using Microsoft.Xna.Framework;using StardewModdingAPI;using StardewModdingAPI.Events;using StardewModdingAPI.Utilities;using StardewValley;namespace SalsFirstMod {public class ModEntry : Mod {// Public Methods    // Mod entry point    public override void Entry(IModHelper helper)    {        helper.Events.Input.ButtonPressed += this.OnButtonPressed;    }// Private Methods    // Raised after the player presses a button    private void OnButtonPressed(object? sender, ButtonPressedEventArgs e)    {        // Ignore if the player hasn't loaded a save        if (!Context.IsWorldReady)            return;        // Print button presses to the console window        this.Monitor.Log($"{Game1.player.Name} pressed {e.Button}.", LogLevel.Debug);    }}}

manifest.json

{"Name": "SalsFirstMod","Author": "Sal","Version": "1.0.0","Description": "Just prints crap to the console","UniqueID": "Sal.SalsFirstMod","EntryDll":  "SalsFirstMod.dll","MinimumAPIVersion": "4.0.0","UpdateKeys":  []}

My project file (Using Visual Studio 2022)`<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup><RootNamespace>SalsFirstMod</RootNamespace><TargetFramework>net6.0</TargetFramework></PropertyGroup><ItemGroup><PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="4.1.1" /></ItemGroup></Project>

I was hoping the game would run and button presses would be printed to the console during game play, as is the goal of the tutorial. I've tried:

  • restarting my computer and VS.
  • I asked ChatGPT oop
  • I looked at the 'main' files of mods on GitHub to see if they were doing anything different. Not as far as I can tell except that other people were using a different class definition than the tutorial.
  • In the tutorial, they defined the ModEntry class as internal sealed class ModEntry : Mod. I changed it to 'public class'.
  • I made sure my assembly name matches my namespace
  • I made sure it was creating the correct files in the SMAPI Mods folder (it creates a folder called 'SalsFirstMod' containing manifest.json and SalsFirstMod.dll.
  • I deleted those files to make sure it was updated and rebuilt.
  • Saw that others have had this problem before. This person on reddit asked about it 8 months ago but got no responses. In another thread, they suggested running stardew valley from the command prompt in the folder. This yielded the same results. They also suggested installing mono, but after downloading the 64 bit msi installer, windows said "The installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package." So I didn't try that.

Viewing all articles
Browse latest Browse all 3067

Trending Articles