// Need to verify that this is a valid CLR assembly.
if (!pILImage->CheckILFormat())
- ThrowHR(COR_E_BADIMAGEFORMAT, BFA_BAD_IL);
+ THROW_BAD_FORMAT(BFA_BAD_IL, pILImage.GetValue());
LoaderAllocator* pLoaderAllocator = NULL;
if (SUCCEEDED(pBinderContext->GetLoaderAllocator((LPVOID*)&pLoaderAllocator)) && pLoaderAllocator->IsCollectible() && !pILImage->IsILOnly())
{
// Loading IJW assemblies into a collectible AssemblyLoadContext is not allowed
- ThrowHR(COR_E_BADIMAGEFORMAT, BFA_IJW_IN_COLLECTIBLE_ALC);
+ THROW_BAD_FORMAT(BFA_IJW_IN_COLLECTIBLE_ALC, pILImage.GetValue());
}
}
{
// ReadyToRun images are treated as IL images by the rest of the system
if (!pNIImage->CheckILFormat())
- ThrowHR(COR_E_BADIMAGEFORMAT);
+ THROW_BAD_FORMAT(COR_E_BADIMAGEFORMAT, pNIImage.GetValue());
pILImage = pNIImage.Extract();
pNIImage = NULL;
else
{
if (!pNIImage->CheckNativeFormat())
- ThrowHR(COR_E_BADIMAGEFORMAT);
+ THROW_BAD_FORMAT(COR_E_BADIMAGEFORMAT, pNIImage.GetValue());
}
}
#endif // FEATURE_PREJIT
#ifndef DACCESS_COMPILE
SString msgStr;
- if ((imageName != NULL) && (imageName[0] != 0))
- {
- msgStr += W("[");
- msgStr += imageName;
- msgStr += W("] ");
- }
-
SString resStr;
if (resID == 0 || !resStr.LoadResource(CCompRC::Optional, resID))
{
- resStr.LoadResource(CCompRC::Error, MSG_FOR_URT_HR(COR_E_BADIMAGEFORMAT));
+ resStr.LoadResource(CCompRC::Error, BFA_BAD_IL); // "Bad IL format."
}
msgStr += resStr;
+ if ((imageName != NULL) && (imageName[0] != 0))
+ {
+ SString suffixResStr;
+ if (suffixResStr.LoadResource(CCompRC::Optional, COR_E_BADIMAGEFORMAT)) // "The format of the file '%1' is invalid."
+ {
+ SString suffixMsgStr;
+ suffixMsgStr.FormatMessage(FORMAT_MESSAGE_FROM_STRING, (LPCWSTR)suffixResStr, 0, 0, imageName);
+ msgStr.AppendASCII(" ");
+ msgStr += suffixMsgStr;
+ }
+ }
+
#ifdef _DEBUG
if (0 != strcmp(cond, "FALSE"))
{