Also removed rethrowing of an exception inside AssemblyName.GetAssemblyName that sometimes resulted into two identical exceptions getting nested into each other.
Fixes #11499
<Compile Include="$(BclSourcesRoot)\System\AppDomainUnloadedException.cs" />
<Compile Include="$(BclSourcesRoot)\System\ArgIterator.cs" />
<Compile Include="$(BclSourcesRoot)\System\Attribute.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\BadImageFormatException.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\BitConverter.cs" />
<Compile Include="$(BclSourcesRoot)\System\Boolean.cs" />
<Compile Include="$(BclSourcesRoot)\System\Buffer.cs" />
namespace System
{
[Serializable]
- public class BadImageFormatException : SystemException
+ public partial class BadImageFormatException : SystemException
{
private String _fileName; // The name of the corrupt PE file.
private String _fusionLog; // fusion log (when applicable)
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System
+{
+ public partial class BadImageFormatException
+ {
+ // Do not delete: this is invoked from native code.
+ private BadImageFormatException(string fileName, string fusionLog, int hResult)
+ : base(null)
+ {
+ HResult = hResult;
+ _fileName = fileName;
+ _fusionLog = fusionLog;
+ SetMessageField();
+ }
+ }
+}
SString sFileName(gc.filename->GetBuffer());
PEImageHolder pImage = PEImage::OpenImage(sFileName, MDInternalImport_NoCache);
- EX_TRY
- {
- // Allow AssemblyLoadContext.GetAssemblyName for native images on CoreCLR
- if (pImage->HasNTHeaders() && pImage->HasCorHeader() && pImage->HasNativeHeader())
- pImage->VerifyIsNIAssembly();
- else
- pImage->VerifyIsAssembly();
- }
- EX_CATCH
- {
- Exception *ex = GET_EXCEPTION();
- EEFileLoadException::Throw(sFileName,ex->GetHR(),ex);
- }
- EX_END_CATCH_UNREACHABLE;
+ // Allow AssemblyLoadContext.GetAssemblyName for native images on CoreCLR
+ if (pImage->HasNTHeaders() && pImage->HasCorHeader() && pImage->HasNativeHeader())
+ pImage->VerifyIsNIAssembly();
+ else
+ pImage->VerifyIsAssembly();
SString sUrl = sFileName;
PEAssembly::PathToUrl(sUrl);