+ if (throw_on_unmappable_set || best_fit_mapping_set || exact_spelling_set || set_last_error_set) {
+ set_best_fit = typeof (MethodBuilder).
+ GetMethod ("set_BestFitMapping", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ set_throw_on = typeof (MethodBuilder).
+ GetMethod ("set_ThrowOnUnmappableChar", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ set_exact_spelling = typeof (MethodBuilder).
+ GetMethod ("set_ExactSpelling", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ set_set_last_error = typeof (MethodBuilder).
+ GetMethod ("set_SetLastError", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+
+ if ((set_best_fit == null) || (set_throw_on == null) ||
+ (set_exact_spelling == null) || (set_set_last_error == null)) {
+ Report.Error (-1, Location,
+ "The ThrowOnUnmappableChar, BestFitMapping, SetLastError, " +
+ "and ExactSpelling attributes can only be emitted when running on the mono runtime.");
+ return null;
+ }
+ }
+
+ try {
+ MethodBuilder mb = builder.DefinePInvokeMethod (
+ name, dll_name, entry_point, flags | MethodAttributes.HideBySig | MethodAttributes.PinvokeImpl,
+ CallingConventions.Standard, ret_type, param_types, cc, charset);
+
+ if (preserve_sig)
+ mb.SetImplementationFlags (MethodImplAttributes.PreserveSig);
+
+ if (throw_on_unmappable_set)
+ set_throw_on.Invoke (mb, 0, null, new object [] { throw_on_unmappable }, null);
+ if (best_fit_mapping_set)
+ set_best_fit.Invoke (mb, 0, null, new object [] { best_fit_mapping }, null);
+ if (exact_spelling_set)
+ set_exact_spelling.Invoke (mb, 0, null, new object [] { exact_spelling }, null);
+ if (set_last_error_set)
+ set_set_last_error.Invoke (mb, 0, null, new object [] { set_last_error }, null);