diff --git a/src/coreclr/dlls/mscorrc/mscorrc.rc b/src/coreclr/dlls/mscorrc/mscorrc.rc index a858eeff594308..cb371763691e65 100644 --- a/src/coreclr/dlls/mscorrc/mscorrc.rc +++ b/src/coreclr/dlls/mscorrc/mscorrc.rc @@ -151,6 +151,7 @@ STRINGTABLE DISCARDABLE BEGIN IDS_EE_THREAD_APARTMENT_NOT_SUPPORTED "The system does not support the %1 thread apartment." IDS_EE_NDIRECT_UNSUPPORTED_SIG "Method's type signature is not PInvoke compatible." + IDS_EE_NDIRECT_UNSUPPORTED_UNMANAGEDCALLERSONLY "Method '%1.%2' cannot be marked with both DllImportAttribute and UnmanagedCallersOnlyAttribute." IDS_EE_COM_UNSUPPORTED_SIG "Method's type signature is not Interop compatible." IDS_EE_COM_UNSUPPORTED_TYPE "The method returned a COM Variant type that is not Interop compatible." IDS_EE_MULTIPLE_CALLCONV_UNSUPPORTED "Multiple unmanaged calling conventions are specified. Only a single calling convention is supported." diff --git a/src/coreclr/dlls/mscorrc/resource.h b/src/coreclr/dlls/mscorrc/resource.h index 964cb7128325d9..fc103677bcd4b2 100644 --- a/src/coreclr/dlls/mscorrc/resource.h +++ b/src/coreclr/dlls/mscorrc/resource.h @@ -35,6 +35,7 @@ #define IDS_DS_DSOTHREADMODEL 0x1707 #define IDS_EE_NDIRECT_UNSUPPORTED_SIG 0x1708 +#define IDS_EE_NDIRECT_UNSUPPORTED_UNMANAGEDCALLERSONLY 0x1709 #define IDS_EE_NDIRECT_BADNATL 0x170a #define IDS_EE_NDIRECT_LOADLIB_WIN 0x170b #define IDS_EE_NDIRECT_GETPROCADDRESS_WIN 0x170c diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index 7f16554ce79196..858c42329c0720 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -3415,7 +3415,6 @@ BOOL NDirect::MarshalingRequired( return FALSE; } - // factorization of CreateNDirectStubWorker static MarshalInfo::MarshalType DoMarshalReturnValue(MetaSig& msig, mdParamDef* params, @@ -4291,7 +4290,13 @@ static void CreateNDirectStubAccessMetadata( // P/Invoke marked with UnmanagedCallersOnlyAttribute is not // presently supported. if (pMD->HasUnmanagedCallersOnlyAttribute()) - COMPlusThrow(kNotSupportedException, IDS_EE_NDIRECT_UNSUPPORTED_SIG); + { + SString namespaceOrClassName; + SString methodName; + pMD->GetMethodInfoNoSig(namespaceOrClassName, methodName); + COMPlusThrow(kNotSupportedException, IDS_EE_NDIRECT_UNSUPPORTED_UNMANAGEDCALLERSONLY, + namespaceOrClassName.GetUnicode(), methodName.GetUnicode()); + } // Check to see if we need to do LCID conversion. lcidArg = GetLCIDParameterIndex(pMD); diff --git a/src/mono/mono/metadata/marshal.c b/src/mono/mono/metadata/marshal.c index 03379d5c2fd9fe..e68fba963e70e6 100644 --- a/src/mono/mono/metadata/marshal.c +++ b/src/mono/mono/metadata/marshal.c @@ -3582,7 +3582,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions, * In AOT mode and embedding scenarios, it is possible that the icall is not registered in the runtime doing the AOT compilation. * Emit a wrapper that throws a NotSupportedException. */ - get_marshal_cb ()->mb_emit_exception (mb, "System", "NotSupportedException", "Method canot be marked with both DllImportAttribute and UnmanagedCallersOnlyAttribute"); + get_marshal_cb ()->mb_emit_exception (mb, "System", "NotSupportedException", "Method cannot be marked with both DllImportAttribute and UnmanagedCallersOnlyAttribute"); goto emit_exception_for_error; } else if (!pinvoke && !piinfo->addr && !aot) { /* if there's no code but the error isn't set, just use a fairly generic exception. */