From 96f474c67e83b178c3a27afc1540953948610c73 Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 21 Sep 2016 06:50:03 -0700 Subject: Fix CrossGen error reporting when input is missing (#7287) Currently, running "crossgen foo.dll" when foo.dll does not exist produces a misleading error message "The image being compiled is not a .NET assembly". The reason is CrossGen ignores the actual error code reported during initial asssembly load and verification, and always reports the error as NGEN_E_FILE_NOT_ASSEMBLY. This change removes that logic, since the original error code is much more likely to be useful. --- src/vm/compile.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src/vm/compile.cpp') diff --git a/src/vm/compile.cpp b/src/vm/compile.cpp index 4e39909735..4aefe2f4e9 100644 --- a/src/vm/compile.cpp +++ b/src/vm/compile.cpp @@ -382,7 +382,6 @@ HRESULT CEECompileInfo::LoadAssemblyByPath( Assembly * pAssembly; HRESULT hrProcessLibraryBitnessMismatch = S_OK; - bool verifyingImageIsAssembly = false; // We don't want to do a LoadFrom, since they do not work with ngen. Instead, // read the metadata from the file and do a bind based on that. @@ -416,9 +415,6 @@ HRESULT CEECompileInfo::LoadAssemblyByPath( fExplicitBindToNativeImage ? MDInternalImport_NoCache : MDInternalImport_Default); } -#if defined(FEATURE_WINDOWSPHONE) - verifyingImageIsAssembly = true; -#endif // FEATURE_WINDOWSPHONE if (fExplicitBindToNativeImage && !pImage->HasReadyToRunHeader()) { pImage->VerifyIsNIAssembly(); @@ -427,8 +423,6 @@ HRESULT CEECompileInfo::LoadAssemblyByPath( { pImage->VerifyIsAssembly(); } - - verifyingImageIsAssembly = false; // Check to make sure the bitness of the assembly matches the bitness of the process // we will be loading it into and store the result. If a COR_IMAGE_ERROR gets thrown @@ -552,11 +546,7 @@ HRESULT CEECompileInfo::LoadAssemblyByPath( } EX_CATCH_HRESULT(hr); - if (verifyingImageIsAssembly && hr != S_OK) - { - hr = NGEN_E_FILE_NOT_ASSEMBLY; - } - else if ( hrProcessLibraryBitnessMismatch != S_OK && ( hr == COR_E_BADIMAGEFORMAT || hr == HRESULT_FROM_WIN32(ERROR_BAD_EXE_FORMAT) ) ) + if ( hrProcessLibraryBitnessMismatch != S_OK && ( hr == COR_E_BADIMAGEFORMAT || hr == HRESULT_FROM_WIN32(ERROR_BAD_EXE_FORMAT) ) ) { hr = hrProcessLibraryBitnessMismatch; } -- cgit v1.2.3