Jump to content

FileNotFoundException: Could not load file or assembly


Recommended Posts

Hi!

I'm trying to make what is more or less a hello world mod. I got it running okey, but when adding another line of code accessing the FlightGlobals variable I get the following error:

FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

Any ideas of what this means? I'm using VS2017, chose net 3.5 when creating the project (but this is not visible in the project file) and added references to Assembly-CSharp, Assembly-CSharp-firstpass, UnityEngine, UnityEngine.UI.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using UnityEngine;

namespace NamespaceName
{
    [KSPAddon(KSPAddon.Startup.FlightAndEditor, false /*once*/)]
    public class ModName : MonoBehaviour
    {
        public void Update()
        {
            if (Input.GetKeyDown(KeyCode.F5))
            {
                Debug.Log("F5");

				// Causes exception when the following two rows are added:
                Vessel vessel = FlightGlobals.ActiveVessel;
                Debug.Log("Name: " + vessel.name);
            }
        }
    }
}

 

Link to comment
Share on other sites

2 minutes ago, Katten said:

I did choose 3.5 when creating the project. There doesn't seem to exist a way to confirm this choice in 2017 tho.

Did you make sure you chose the project type "Class Library (.NET Framework)". If you did then your project properties page should include a target framework drop down with 3.5 selected 

Link to comment
Share on other sites

1 minute ago, Aelfhe1m said:

Did you make sure you chose the project type "Class Library (.NET Framework)". If you did then your project properties page should include a target framework drop down with 3.5 selected 

Aha! I chose Universal Windows! Trying "Class Library (.NET Standard)" now...

I chose 3.5 again, but after creating the project it says Application -> Target framework = .NET standard 1.4
Sounds weird?

Link to comment
Share on other sites

1 minute ago, Katten said:

Aha! I chose Universal Windows! Trying "Class Library (.NET Standard)" now...

I chose 3.5 again, but after creating the project it says Application -> Target framework = .NET standard 1.4
Sounds weird?

No Standard won't work either. It needs to be "Class Library (.NET Framework)". 

Link to comment
Share on other sites

3 minutes ago, Aelfhe1m said:

No Standard won't work either. It needs to be "Class Library (.NET Framework)". 

Aha again! There is no such choice for me, so probably need to install it... thanks, checking! I wouldn't have guessed, considering the first option actually was able to run, catch key events and print debug output

Link to comment
Share on other sites

21 minutes ago, Aelfhe1m said:

No Standard won't work either. It needs to be "Class Library (.NET Framework)". 

Let it be known for all future that Aelfhe1m rocks!

Totally worked, after (for reference) clicking "Tools -> Get Tools and Features -> Modify -> Workloads -> .NET desktop development."

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...