Katten

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);
            }
        }
    }
}

 

Share this post


Link to post
Share on other sites
5 minutes ago, Katten said:

'System.Runtime, Version=4.0.20.0

KSP plugins should be built against .NET Framework 3.5

Share this post


Link to post
Share on other sites
1 minute ago, Aelfhe1m said:

KSP plugins should be built against .NET Framework 3.5

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

Share this post


Link to post
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 

Share this post


Link to post
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?

Share this post


Link to post
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)". 

Share this post


Link to post
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

Share this post


Link to post
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."

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now