[英]“Predefined type 'System.*' is not defined or imported” Error, visual studio code, omnisharp
[英]Xamarin Studio OS X Cocoa Application Project Source Code Filled with “Predefined 'System.*' is not defined”
因此,我下載了適用於Mac OS X的Xamarin Studio,將其打開,它說我需要安裝Mono框架,因此我單擊了消息中的按鈕,下載了Mono,然后安裝了它。 到目前為止,一切都進行得很順利。 然后,回到Xamarin Studio中,我用C#創建了一個新的Mac OS X Cocoa項目,我將其稱為“我的應用程序”(文件為MyApp.csproj
),它是名為“ RandDevX”的新解決方案的一部分。 但是,當我打開該項目(將其打開到AppDelegate.cs
文件中)時,我注意到幾乎所有內容都在其下划線了一個紅色的錯誤:
AppDelegate.cs:
using AppKit;
using Foundation;
namespace MyApp {
[Register("AppDelegate")]
public class AppDelegate : NSApplicationDelegate {
public AppDelegate() {
}
public override void DidFinishLaunching(NSNotification notification) {
// Insert code here to initialize your application
}
public override void WillTerminate(NSNotification notification) {
// Insert code here to tear down your application
}
}
}
Main.cs:
using AppKit;
namespace MyApp {
static class MainClass {
static void Main(string[] args) {
NSApplication.Init();
NSApplication.Main(args);
}
}
}
( AppDelegate.cs
的源代碼顯示了所有彎曲的行 )
( Main.cs
的源代碼顯示了所有Main.cs
的行 )
因此,我將鼠標懸停在Main.cs
帶下划線的代碼上,以檢查發生了什么,這就是我得到的:
using AppKit;
懸停在AppKit
時using AppKit;
(第一行),它表示Using directive is unnecessary
。 MainClass
懸停在static class MainClass
(第5行)中的static class MainClass
,它static class MainClass
Error: Predefined type 'System.Object' is not defined or imported
。 void
中static void Main
(第7行),它表示Error: Predefined type 'System.Void' is not defined or imported
。 string
中string[] args
(第7行),它表示Error: Predefined type 'System.String' is not defined or imported
, ...你就明白了。 我對Xamarin感到非常興奮,最終能夠在移動開發人員中使用C#,因此,我非常感謝能提供幫助的任何人!
提前多謝
----六角
我重新安裝了所有內容(我的意思是,所有內容;我在計算機上搜索了所有包含“ Xamarin”的文件並刪除了它們,並使用腳本從其網站上卸載了mono框架(我還運行了sudo pkgutil --forget sudo pkgutil --forget com.xamarin.mono-MRE.pkg
刪除運行時環境。然后,我使用安裝程序重新安裝了Xamarin(由於某種原因沒有安裝Xamarin.Mac
因此我不得不運行兩次),現在一切正常!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.