mac OS c#信息中的c#编组信息问题

mac OS c#信息中的c#编组信息问题,c#,xcode,macos,visual-studio,C#,Xcode,Macos,Visual Studio,因此,我使用visual studio for mac编写了一个C#桌面应用程序定位,但它返回了一个错误:“未能查找所需的封送信息。其他信息:选择器:conformsToProtocol:类型:ViewController。” 这是一款PGP应用程序,可对用户键入的消息进行加密: 代码如下: Encrptor1.cs: using AppKit; using System; using System.Collections.Generic; using System.IO; using Syst

因此,我使用visual studio for mac编写了一个C#桌面应用程序定位,但它返回了一个错误:“未能查找所需的封送信息。其他信息:选择器:conformsToProtocol:类型:ViewController。”

这是一款PGP应用程序,可对用户键入的消息进行加密:

代码如下:

Encrptor1.cs:
using AppKit;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Security.Cryptography;
using System.Text;


namespace ByteOrbitPrivacyCannonMacBuild
{
    class Encryptor1

    {
        public static string IV = "1a1a1a1a1a1a1a1a";
        public static string Key = "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a13";

        public static string Encrypt(string decrypted)
        {
            byte[] textbytes = ASCIIEncoding.ASCII.GetBytes(decrypted);
            AesCryptoServiceProvider endec = new AesCryptoServiceProvider();
            endec.BlockSize = 128;
            endec.KeySize = 256;
            endec.IV = ASCIIEncoding.ASCII.GetBytes(IV);
            endec.Key = ASCIIEncoding.ASCII.GetBytes(Key);
            endec.Padding = PaddingMode.PKCS7;
            endec.Mode = CipherMode.CBC;
            ICryptoTransform icrypt = endec.CreateEncryptor(endec.Key, endec.IV);
            byte[] enc = icrypt.TransformFinalBlock(textbytes, 0, textbytes.Length);
            icrypt.Dispose();
            return Convert.ToBase64String(enc);
        }

        public static string Decrypted(string encrypted)
        {

            DateTime creation = File.GetCreationTime(@"C:\encryptedmessagehere.txt");

            string asString = creation.ToString("MM/dd/yyyy hh:mm:ss tt");


            var created = ViewController.verify;
            if (created != asString)
            {
                var alert = new NSAlert()
                {
                    AlertStyle = NSAlertStyle.Critical,
                    InformativeText = "That is incorrect, access is denied",
                    MessageText = "That is incorrect, access is denied",
                };
                alert.RunModal();
            }
            else if (created == asString)
            {

                byte[] textbytes = Convert.FromBase64String(encrypted);
                AesCryptoServiceProvider endec = new AesCryptoServiceProvider();
                endec.BlockSize = 128;
                endec.KeySize = 256;
                endec.IV = ASCIIEncoding.ASCII.GetBytes(IV);
                endec.Key = ASCIIEncoding.ASCII.GetBytes(Key);
                endec.Padding = PaddingMode.PKCS7;
                endec.Mode = CipherMode.CBC;
                ICryptoTransform icrypt = endec.CreateDecryptor(endec.Key, endec.IV);
                byte[] enc = icrypt.TransformFinalBlock(textbytes, 0, textbytes.Length);
                icrypt.Dispose();

                if (ViewController.verify == created)
                {
                    return System.Text.ASCIIEncoding.ASCII.GetString(enc);
                }
                else if (ViewController.verify != created)
                {
                    var alert = new NSAlert()
                    {
                        AlertStyle = NSAlertStyle.Critical,
                        InformativeText = "It looks like you are trying to fool me by using a key file that was not created for this message. Nice Try.",
                        MessageText = "It looks like you are trying to fool me by using a key file that was not created for this message. Nice Try.",
                    };
                    alert.RunModal();
                    
                }

            }

            return encrypted;
        }
    }
}

Main.cs
  
using AppKit;

namespace ByteOrbitPrivacyCannonMacBuild
{
    static class MainClass
    {
        static void Main(string[] args)
        {
            NSApplication.Init();
            NSApplication.Main(args);

// This is where the error occurs.
        }
    }
}

ViewController.cs

using System;
using System.IO;
using AppKit;
using Foundation;
using static System.Net.Mime.MediaTypeNames;

namespace ByteOrbitPrivacyCannonMacBuild
{
    public partial class ViewController : NSViewController
    {
        public ViewController(IntPtr handle) : base(handle)
        {
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Do any additional setup after loading the view.
        }

        public override NSObject RepresentedObject
        {
            get
            {
                return base.RepresentedObject;
            }
            set
            {
                base.RepresentedObject = value;
                // Update the view, if already loaded.
            }
        }
            partial void ClickDecrypt(Foundation.NSObject sender)
        {
            string decrypt;
            StreamReader sr = new StreamReader("encryptedmessagehere.txt");
            string line = sr.ReadLine();

            decrypt = Encryptor1.Decrypted(Convert.ToString(line));
            Console.WriteLine("Encrypted message is: " + line);
           
        }
        StreamReader sr = new StreamReader("encryptedmessagehere.txt");

        public static string verify;



        partial void ClickEncrypt(Foundation.NSObject sender)
        {
            

            verify = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt");
            string enctxt = Encryptor1.Encrypt(Message + " Message Created at: " + verify);
            System.IO.File.WriteAllText(@"/encryptedmessagehere.txt", enctxt);
        }

    }

}
如果您有任何关于为什么会发生这种情况的想法,我们将不胜感激,谢谢