使用していない変数の宣言を省略すると
実行時にエラーが発生します。
エラー発生の理由を教えて下さい。
よろしくお願いします。
Option Explicit Class bind Function f(a,b) f=b.f(a) End Function End Class Class pureget Private v Function f(x) v = x f = Me End Function End Class Class cw Private v Function f(x) Console.WriteLine(x.v) f = me End Function End Class Class pureput Function f(x) f = new cw f.v = x End Function End Class Class exec Function f(x) f =x.f(x.v) End Function End Class Module Program Sub Main() dim getput, bind, a, b, e bind = new bind a = new pureget b = new pureput a.f("Hello") getput = bind.f(a,b) e = new exec e.f(getput) End Sub End Module
“Class cw”の”Private v”を省略して実行すると以下のエラーが発生します。
Microsoft (R) Visual Basic Compiler version 3.6.0-4.20224.5 (ec77c100) Copyright (C) Microsoft Corporation. All rights reserved. Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMethodException: Method 'cw.v' not found. at System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) [0x00710] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at Microsoft.VisualBasic.CompilerServices.LateBinding.LateSet (System.Object o, System.Type objType, System.String name, System.Object[] args, System.String[] paramnames) [0x00082] in <78b8fb9203f94730bb724970afd421d2>:0 at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet (System.Object Instance, System.Type Type, System.String MemberName, System.Object[] Arguments, System.String[] ArgumentNames, System.Type[] TypeArguments) [0x00001] in <78b8fb9203f94730bb724970afd421d2>:0 at pureput.f (System.Object x) [0x00007] in :0 at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 --- End of inner exception stack trace --- at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at System.RuntimeType.InvokeMember (System.String name, System.Reflection.BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) [0x006e7] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet (System.Object o, System.Type objType, System.String name, System.Object[] args, System.String[] paramnames, System.Boolean[] CopyBack) [0x00052] in <78b8fb9203f94730bb724970afd421d2>:0 at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet (System.Object Instance, System.Type Type, System.String MemberName, System.Object[] Arguments, System.String[] ArgumentNames, System.Type[] TypeArguments, System.Boolean[] CopyBack) [0x00001] in <78b8fb9203f94730bb724970afd421d2>:0 at bind.f (System.Object a, System.Object b) [0x00001] in :0 at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <9f0df102fe6e4cfea29d2e46f585d8a5>:0 --- End of inner exception stack trace --- 以下省略
以上ですが、よろしくお願いします。
回答3件
あなたの回答
tips
プレビュー