• 締切済み

ubuntu上のMonoDevelopがダメ

ubuntu32の上にMonoDevelopをインストールして、ネットワークプログラムのサンプルを動かそうとしています。System.Netのusingが必要ということで、referenseにSystem.Netを参照できるようにしましたが、コンパイルすると、そういうライブラリは存在しない、と怒られます。 具体的には、下記のようなプログラムを書き、<エラー>のようなメッセージが出てしまいます。参照はできるのに、何故このようなメッセージが出るのでしょうか。どなたかMonoプロジェクトに詳しい方がいましたら教えていただけませんか。当方、MonoDevelopも.NET Frameworkもほとんど知識がありません。なので、基本的なところが分っていません。 よろしくお願いします。 using System; using System.Windows.Forms; using System.Net; namespace Sample1 { class Sample1 : Form { private Label lb1, lb2; public static void Main () { Application.Run(new Sample1()); } public Sample1() { this.Text = "サンプル"; this.Width = 300; this.Height = 100; string hn = Dns.GetHostName(); <エラー>The name 'Dns' does not exist in the current context. IPHostEntry ih = Dns.GetHostEntry(hn); <エラー>The type or namespace name 'IPHostEntry' could not be found. IPAddress ia = ih.AddressList[0]; <エラー>The type or namespace name 'IPAddress' could not be found.

みんなの回答

回答No.1

非常に紛らわしいが、アセンブリ名と入っている名前空間が異なることが割りとある。 例えば、System.Net.Dnsは http://docs.go-mono.com/?link=T%3aSystem.Net.Dns >Assembly: System (in System.dll) って書いてあるから、参照するのはSystem.NetではなくSystemが正しい。 #ちなみに同じ名前空間のクラスでも同じアセンブリにあるとは限らない。 例えばSystem.Int32(いわゆるint)はmscorlib.dllにある。(これはあえて除外しない限り自動的に参照される) http://docs.go-mono.com/?link=T%3aSystem.Int32 でも、System.UriはSystem.dllにある。 http://docs.go-mono.com/?link=T%3aSystem.Uri

japanist
質問者

お礼

BIGLOBE相談室には初めて投稿しました。 たった一晩で、ものすごい数の質問がなされているのには驚きました。 が、すぐに埋まってしまう質問に対して迅速に回答していただいたのには、 もっと驚きました。 'himajin100000'さん、ありがとうございました。 Referenseに「System」を追加したら、無事ビルドできました。 よちよち歩きなので、また質問させてもらうことも多いと思いますが、 よろしくお願いします。

全文を見る
すると、全ての回答が全文表示されます。

関連するQ&A

  • Windowsフォームの表示

    Visual C++ 2005(Express Edition)で、windowsフォームを3個作りました。 1個目をForm1.h、2個目をForm2.h、3個目をForm3.h、メインプロジェクトは、Sample.cpp, ファイルとします。 Form1にボタンbutton1を作成し、ボタンをクリックしたイベントが発生したとき、Form2を表示させます。 Form2には、ボタンbutton2があります。 Form1と同様に、Form2のボタンをクリックするとForm3の画面が表示されるようにします。 ところが、以下のソースファイルで書いたところ、Form2とForm3は、名前空間に存在しませんという意味のエラーが生じます。 Form2とForm3をインスタンス化し、Show()メッソドで、画面を表示させる方法です。 しかし、Form1とForm2だけのファイルですと、先のソースの書き方で上手くいきます。 何か、書き方が異なるのでしょうか?正しい書き方を教えてくださいますとありがたいです。 なお、C++/CLIの文法に沿った、ソースコードでお願いします。 <ソースファイル> ----Form1.h----------------------------- #pragma once #include "stdafx.h" #include "Form2.h" #include "Form3.h" namespace Sample { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Form1 の概要 /// /// 警告: このクラスの名前を変更する場合、このクラスが依存するすべての .resx ファイルに関連付けられた /// マネージ リソース コンパイラ ツールに対して 'Resource File Name' プロパティを /// 変更する必要があります。この変更を行わないと、 /// デザイナと、このフォームに関連付けられたローカライズ済みリソースとが、 /// 正しく相互に利用できなくなります。 /// </summary> public ref class Form1 : public System::Windows::Forms::Form { //button1を作成 //省略 #pragma endregion private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { Form2^ a = gcnew Form2(); a->Show(); } }; } [EOF] --------------------------------------- ----Form2.h---------------------------- #pragma once #include "Form1.h" #include "Form3.h" using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; namespace Sample { /// <summary> /// IsotopeInput の概要 /// /// 警告: このクラスの名前を変更する場合、このクラスが依存するすべての .resx ファイルに関連付けられた /// マネージ リソース コンパイラ ツールに対して 'Resource File Name' プロパティを /// 変更する必要があります。この変更を行わないと、 /// デザイナと、このフォームに関連付けられたローカライズ済みリソースとが、 /// 正しく相互に利用できなくなります。 /// </summary> public ref class Form2 : public System::Windows::Forms::Form { //button2を作成 //省略 } #pragma endregion private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { Form3^ b = gcnew Form3(); b->Show(); } }; } [EOF] --------------------------------------- -------Form3.h-------------------------- #pragma once #include "stdafx.h" #include "Form1.h" #include "Form2.h" using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; namespace Sample { /// <summary> /// Result の概要 /// /// 警告: このクラスの名前を変更する場合、このクラスが依存するすべての .resx ファイルに関連付けられた /// マネージ リソース コンパイラ ツールに対して 'Resource File Name' プロパティを /// 変更する必要があります。この変更を行わないと、 /// デザイナと、このフォームに関連付けられたローカライズ済みリソースとが、 /// 正しく相互に利用できなくなります。 /// </summary> public ref class Form3 : public System::Windows::Forms::Form { //省略 } #pragma endregion }; } [EOF] --------------------------------------------------------- Sample.cpp----------------------------------------------- // Sample.cpp : メイン プロジェクト ファイルです。 #include "stdafx.h" #include "Form1.h" #include "Form2.h" #include "Form3.h" using namespace Sample; [STAThreadAttribute] int main(array<System::String ^> ^args) { // コントロールが作成される前に、Windows XP ビジュアル効果を有効にします Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); // メイン ウィンドウを作成して、実行します Application::Run(gcnew Form1()); return 0; } [EOF] ------------------------------------------------------------

  • 別スレッドからメインスレッドのテキストボックスに文字を表示させたい

    Visual C++ 2005 Express Editionを使用している初心者です。 タイトルの方法がどうしてもわからないので教えてください。 うまく説明できないので聞きたいところのコードを載せます。 //SAMPLE.cpp #include "stdafx.h" #include "Form1.h" using namespace SAMPLE; int main(array<System::String ^> ^args) { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); Application::Run(gcnew Form1()); } //Form1.h #include <process.h> #include <vcclr.h> namespace SAMPLE { unsigned __stdcall counter(void *arg); int thread_id1; unsigned dummy; using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form { public:Form1(void) { InitializeComponent(); //別スレッド起動 thread_id1=_beginthreadex(NULL,0,counter,(void *)1,0,&dummy); } private: System::Windows::Forms::TextBox^ textBox1; private: System::ComponentModel::Container ^components; void InitializeComponent(void) { this->textBox1 = (gcnew System::Windows::Forms::TextBox()); //省略(コンポーネント初期化) } private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { } }; unsigned __stdcall counter(void *arg){ //別スレッド //ここで文字列を記述して上のtextBox1に表示したい return 0; } } 初歩的なことかもしれませんが、 よろしくお願いします。

  • 「識別子がクラス名でも名前空間名でもありません。」と出ます;

    このサイト様にある http://sorceryforce.com/manageddirectx/direct3d_cameraoperation.html Geometry::DegreeToRadian(); を自分のプログラムで使いたいのですが (※MSDNではこれです http://msdn.microsoft.com/ja-jp/library/ms889482.aspx) (マウスを乗せると ref class Microsoft::DirectX::Direct3D::Geometry sealed と出ます。) >error C2653: 'Geometry' : 識別子がクラス名でも名前空間名でもありません。 と出てしまいそのままでは動いてくれず、 >using namespace System; >using namespace System::Collections::Generic; >using namespace System::Diagnostics; >using namespace System::Drawing; >using namespace System::Text; >using namespace System::Windows::Forms; >using namespace Microsoft::DirectX; >using namespace Microsoft::DirectX::Direct3D; この部分をヘッダー領域に追記してみたのですが >error C2871: 'System' : この名前を指定された名前空間は存在しません。 他一式全部エラーが出てしまいます。 一応簡単な名前空間の勉強は済ませたつもりだったのですがさっぱり解りません; 私は何を間違えていて、 何を勘違いしていたり、勉強すべきなのか指摘して頂けると幸いです。 orz

  • アメブロで、スクリプトエラーを回避したい

    アメブロで、スクリプトエラーを回避する方法を教えてください。 以下のプログラムは、C#で作っています。 アメブロの検索画面にてテキストボックスに代入すると、スクリプトエラーが出ます。 この表示を出さないようにするには、どのようにしたらいいですか。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WebBrowserTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.Text = "MyBrowser"; this.comboBox1.Text = "http://search.ameba.jp/"; //this.comboBox1.Text = "http://www.google.co.jp/webhp?sourceid=navclient-ff"; } /// <summary> /// DocumentCompletedイベントは、ドキュメントの読み込みが終了したときに発生します。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { HtmlElementCollection all = webBrowser1.Document.All; HtmlElementCollection forms = all.GetElementsByName("q"); forms[0].InnerText = @"c#"; // テキストボックスに「C#」を入力 }

  • VisualStudio 2008 Express

    無料でネットからダウンロードしたVisualStudio 2008 Express Edition のフォームをつかってGUIの勉強をしています。 非情報系学生のための C/C++ 入門 というサイトにある コースの 「第三回  GUI と画像処理プログラミング 」をやってみましたが、フォーム上のボタンを押せばメッセージボックスが出てくるはずなのに、何も起こりません。 何が原因なのかわかりません。詳しい方、どうか知恵を貸してください。  ちなみにそのサイトのアドレスは以下のとおりです。 http://brain.cc.kogakuin.ac.jp/~kanamaru/lecture/prog1/index.html ボタンをフォームに貼り付けると自動的に生成されるイベントハンドラーに、自分の追加した部分も含めたヘッダーファイルの内容を下に乗せておきます。 // *************************** // Form1.h file #pragma once namespace MyGUI_NET { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Form1 の概要 /// /// 警告: このクラスの名前を変更する場合、このクラスが依存するすべての .resx ファイルに関連付けられた /// マネージ リソース コンパイラ ツールに対して 'Resource File Name' プロパティを /// 変更する必要があります。この変更を行わないと、 /// デザイナと、このフォームに関連付けられたローカライズ済みリソースとが、 /// 正しく相互に利用できなくなります。 /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: ここにコンストラクタ コードを追加します // } protected: /// <summary> /// 使用中のリソースをすべてクリーンアップします。 /// </summary> ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::Button^ button1; protected: protected: private: /// <summary> /// 必要なデザイナ変数です。 /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// デザイナ サポートに必要なメソッドです。このメソッドの内容を /// コード エディタで変更しないでください。 /// </summary> void InitializeComponent(void) { this->button1 = (gcnew System::Windows::Forms::Button()); this->SuspendLayout(); // // button1 // this->button1->BackColor = System::Drawing::Color::PeachPuff; this->button1->Location = System::Drawing::Point(34, 35); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(185, 55); this->button1->TabIndex = 0; this->button1->Text = L"click me"; this->button1->UseVisualStyleBackColor = false; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 12); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(292, 266); this->Controls->Add(this->button1); this->Name = L"Form1"; this->Text = L"Form1"; this->ResumeLayout(false); } #pragma endregion // event handler for button 1 private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { MessageBox::Show("こんにちは"); // 自分が追加した一行 } }; } //****************** どうぞよろしくお願いします。

  • フォームのテキストコントロールへの出力

    Cは分かりますが、C++初心者です。 よろしくお願いします。 namespace sample1 外にある関数から、フォームのコントロールにアクセスするには、 どうしたらいいのでしょうか? ========================================================== #pragma once void DspData( ReadData *readdata ); //コールバック関数宣言 namespace sample1 { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public __gc class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); } protected: void Dispose(Boolean disposing) { if (disposing && components) { components->Dispose(); } __super::Dispose(disposing); } private: System::Windows::Forms::Label * label1; private: System::Windows::Forms::Button * start; private: System::Windows::Forms::Button * end; public: System::Windows::Forms::TextBox * textBox1; private: System::ComponentModel::Container * components; void InitializeComponent(void) { } private: System::Void start_Click(System::Object * sender, System::EventArgs * e) { } }; } //------------------------------------------------ // DspData //------------------------------------------------ void DspData( ReadData *readdata ) { //***↓ここでフォームのテキストボックスへの表示を行いたい。***** textBox1->set_text("ここで出力") return; } ==========================================================

  • クライアント上のC++でサーバーとソケット送信

    クライアント(Windows7)上でC++を使って、サーバー側(Windows)に対してデータを送りたいです (ソケット通信?)。 サーバ受信側はC#を使ったプログラムで以下のような感じで考えてます。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.Net.Sockets; using System.IO; namespace ConsoleApplication1 {   class Program   {     static void Main(string[] args)     {       int port = 2222;       System.Net.IPAddress ip = IPAddress.Parse("127.0.0.1");       System.Net.Sockets.TcpListener server = new TcpListener(ip, port);       Console.WriteLine("Enter押してください");       ConsoleKeyInfo info = Console.ReadKey();       if (info.Key == ConsoleKey.Enter)       {         Console.WriteLine("サーバー待機中");         server.Start();         TcpClient client = server.AcceptTcpClient();         NetworkStream ns = client.GetStream();         StreamWriter sw = new StreamWriter(ns);         Console.WriteLine(sw);       }     }   } } C++のことがよくわかってないので、送信側でC++を使ってどのように 送信すればいいのかわかりません。 送信するデータはINT型で、1秒間に1回、繰り返し送ります。 よろしくお願いします。

  • C言語について質問・・・

    柴田望洋氏の著書である明解C言語(入門編)をもとに visual C++を使ってC言語の勉強をしているのですが まず最初に15+37の計算をしようと書いてあり、とりあえず わからない文法だらけだと思うが、下の通りそのまま入力してみよう と書いてあるのですが、その文章をそのまま入力してみたところ いきなりビルドエラーがでてきました。 ↓が実際の文章です。 /* 整数値15と37の和を表示する */ #include <stdio.h> int main(void) { printf("%d",15+37); /*整数値15と37の和を10進数で表示*/ return(0); } ※本書そのままを入力しており、全角半角のミスはないと思います。 しかし、実際新しいプロジェクトを作り立ち上げた瞬間に意味の分からない 文字の羅列が出てきてそのあとに上の文章を書いてあります。 ↓がその文章 #pragma once namespace lesson01 { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Form1 の概要 /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: ここにコンストラクター コードを追加します // } protected: /// <summary> /// 使用中のリソースをすべてクリーンアップします。 /// </summary> ~Form1() { if (components) { delete components; } } private: /// <summary> /// 必要なデザイナー変数です。 /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// デザイナー サポートに必要なメソッドです。このメソッドの内容を /// コード エディターで変更しないでください。 /// </summary> void InitializeComponent(void) { this->SuspendLayout(); // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 12); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(284, 262); this->Name = L"Form1"; this->Text = L"Form1"; this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); this->ResumeLayout(false); } #pragma endregion private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { } }; } /* 整数値15と37の和を表示する */ #include <stdio.h> int main(void) { printf("%d",15+37); /*整数値15と37の和を10進数で表示*/ return(0); } となっております。 ※lesson01はプロジェクト名です。 ビルドエラーは 1>------ ビルド開始: プロジェクト: lesson01, 構成: Debug Win32 ------ 1> lesson01.cpp 1>lesson01.cpp(10): error C2731: 'main' : 関数はオーバーロードできません。 1> lesson01.cpp(9) : 'main' の宣言を確認してください。 ========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ ========== 保存先はwindows フォームアプリケーションを選び保存しています

  • Visual C++ 2008 Express Editionで作ったプログラムがコンパイルできない

    http://www.asahi-net.or.jp/~yf8k-kbys/newcpp3.html このサイトに掲載されていたプログラムをまねて以下のプログラムをかいてみたのですがコンパイルが通りません。 原因などはどこにあるのか教えていただけないでしょうか。 // test003.cpp : メイン プロジェクト ファイルです。 #include "stdafx.h" //using namespace System; using namespace std; int main(array<System::String ^> ^args) { string name; //Console::WriteLine(L"Hello World"); //return 0; cout << "こんにちは。私はコンピュータです。" << endl; cout << "あなたの名前を入力してください。" << endl; cin >> name; cout << name <<"さん。よろしく。" << endl; }

  • C# でパネルのマウスイベントが取得できない

    OpenNI(キネクトセンサー)のサンプルプログラムは、C#のパネルにbitmapを描画し続けるのですが、 描画中、そのパネルのマウスイベントが生じない(無視されている?)ようです。マウスの位置から 補助線を引いたりしたいのですが、描画中にマウスイベントが取得できる方法をご存知の方、お願いします。以下サンプルソースそのままです。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Text; using System.Windows.Forms; using OpenNI; using System.Threading; using System.Drawing.Imaging; namespace SimpleViewer.net { private unsafe void ReaderThread() { DepthMetaData depthMD = new DepthMetaData(); while (this.shouldRun) { try { this.context.WaitOneUpdateAll(this.depth); } catch (Exception) { } this.depth.GetMetaData(depthMD); lock (this) { Rectangle rect = new Rectangle(0, 0, this.bitmap.Width, this.bitmap.Height); BitmapData data = this.bitmap.LockBits(rect, ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb); ushort* pDepth = (ushort*)this.depth.DepthMapPtr.ToPointer(); // set pixels for (int y = 0; y < depthMD.YRes; ++y) { byte* pDest = (byte*)data.Scan0.ToPointer() + y * data.Stride; for (int x = 0; x < depthMD.XRes; ++x, ++pDepth, pDest += 3) { byte pixel = (byte)this.histogram[*pDepth]; pDest[0] = 0; pDest[1] = pixel; pDest[2] = pixel; } } this.bitmap.UnlockBits(data); } this.Invalidate(); } } private readonly string SAMPLE_XML_FILE = @"../../../Data/SamplesConfig.xml"; private Context context; private ScriptNode scriptNode; private DepthGenerator depth; private Thread readerThread; private bool shouldRun; private Bitmap bitmap; private int[] histogram; } }