简体   繁体   中英

.NET WinForms: Cound not load System.Runtime

I was writing an app for a friend who wanted an easy way to use Morse Code.

I was attempting to use an External Library that I wrote with Morse Code support, and when I try to call it, I get this error, in an External " Control.cs " file. I found happened in both Visual Studio and JB Rider, though Visual Studio gives a different error as it can't debug external sources.

My usings are:

using CainsSharpTools; // <= This is my Library
using System.Diagnostics;
using System.Windows.Forms;

And my function call looks like this:

private void buttonEncode_Click(object sender, System.EventArgs e)
            => textBoxMorse.Text = MorseCode.Parse(textBoxPlain.Text).Value;

The error is

System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
  at at MorseCoder.Form1.buttonEncode_Click(Object sender, EventArgs e)
  at at System.Windows.Forms.Control.OnClick(EventArgs e)
  at at System.Windows.Forms.Button.OnClick(EventArgs e)
  at at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
  at at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
  at at System.Windows.Forms.Control.WndProc(Message& m)
  at at System.Windows.Forms.ButtonBase.WndProc(Message& m)
  at at System.Windows.Forms.Button.WndProc(Message& m)
  at at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
  at at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  at at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  at at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
  at at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
  at at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
  at at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
  at at System.Windows.Forms.Application.Run(Form mainForm)
  at MorseCoder.Program.Main() in C:\Users\caina\source\repos\MorseCoder\MorseCoder\Program.cs:19

i needed to use .NET Standard with my Lib

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM