メモ帳を使用して、新規のテキスト ファイルを作成します。 Paste the following code in the file:
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Metadata;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
namespace EchoExeTest{
[Serializable]
public class testObject
{
public int x;
public int y;
}
[Serializable]
public struct testStruct
{
public int x;
public int y;
}
public class Server {
public static int Main(string [] args) {
Server servObj = new Server();
servObj.Initialize(args);
System.Console.WriteLine("Press ENTER to exit.");
System.Console.ReadLine();
return 0;
}
public void Usage() {
Console.WriteLine(" Usage : ServerExe -chan:channel.config -mode:mode.config");
}
public int Initialize(string[] args) {
int ret=0;
if (args.Length == 0)
Usage();
for (int i=0;i<args.Length;i++) {
if (
String.Compare(args[i],"HELP", true) == 0 ||
String.Compare(args[i],"?", true) == 0 ||
String.Compare(args[i],"/h", true) == 0 ||
String.Compare(args[i],"-h", true) == 0 ||
String.Compare(args[i],"-?", true) == 0 ||
String.Compare(args[i],"/?", true) == 0
) {
Usage();
return -1;
}
String arg = args[i];
String value = null;
if (args[i][0] == '/' || args[i][0] == '-'){
int index = args[i].IndexOf(':');
if (index != -1) {
arg = args[i].Substring(1, index-1);
//Make sure that a colon (:) is not the last character.
if (index == (args[i].Length - 1))
throw new Exception("Argument cannot be empty -> " + args[i]);
value = args[i].Substring(index+1);
}
else
arg = args[i].Substring(1);
}
//Process the input sources.
if (String.Compare(arg, "chan", true) == 0) {
RemotingConfiguration.Configure(value);
}
else if (String.Compare(arg, "mode", true) == 0) {
RemotingConfiguration.Configure(value);
}
}
ret=100;
return ret;
}
}
public class TestClass : MarshalByRefObject {
public int EchoInt(int intval) {
Console.WriteLine("Method Called");
return intval;
}
public string EchoString(string strval) {
Console.WriteLine("Method Called");
return strval;
}
public DateTime EchoDateTime(DateTime dval) {
return dval;
}
public void voidFunc(){
return;
}
public int EchoParam(int intval) {
return intval;
}
public void SendParam(int intval) {
return;
}
public int GetParam() {
return 10;
}
public int EchoRefParam(ref int intval) {
intval++;
return 100;
}
public void SendRefParam(ref int intval) {
intval++;
return;
}
public void OutParam(out int intval) {
intval=100;
}
public testStruct echoStruct(testStruct ts) {
return ts;
}
public testObject echoObject(testObject to) {
Console.WriteLine("Method Called");
return to;
}
public int[] echoArray(int[] intArray) {
return intArray;
}
}
}
Microsoft Knowledge Base の免責: Microsoft Knowledge Baseに含まれている情報は、いかなる保証もない現状ベースで提供されるものです。Microsoft Corporation及びその関連会社は、市場性および特定の目的への適合性を含めて、明示的にも黙示的にも、一切の保証をいたしません。さらに、Microsoft Corporation及びその関連会社は、本文書に含まれている情報の使用及び使用結果につき、正確性、真実性等、いかなる表明・保証も行ないません。Microsoft Corporation、その関連会社及びこれらの権限ある代理人による口頭または書面による一切の情報提供またはアドバイスは、保証を意味するものではなく、かつ上記免責条項の範囲を狭めるものではありません。Microsoft Corporation、その関連会社 及びこれらの者の供給者は、直接的、間接的、偶発的、結果的損害、逸失利益、懲罰的損害、または特別損害を含む全ての損害に対して、状況のいかんを問わず一切責任を負いません。(Microsoft Corporation、その関連会社 またはこれらの者の供給者がかかる損害の発生可能性を了知している場合を含みます。) 結果的損害または偶発的損害に対する責任の免除または制限を認めていない地域においては、上記制限が適用されない場合があります。なお、本文書においては、文書の体裁上の都合により製品名の表記において商標登録表示、その他の商標表示を省略している場合がありますので、予めご了解ください。