Fix assembly load
@@ -323,7 +323,10 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::Load___STATIC__SystemR
NANOCLR_CHECK_HRESULT(g_CLR_RT_TypeSystem.ResolveAll());
NANOCLR_CHECK_HRESULT(g_CLR_RT_TypeSystem.PrepareForExecution());
- if (assm->m_iStaticFields > 0)
+ CLR_RT_MethodDef_Index idx;
+ idx.Set(assm->m_idx, 0);
+
+ if (assm->FindNextStaticConstructor(idx))
{
// need to execute static constructors
g_CLR_RT_ExecutionEngine.SpawnStaticConstructor(g_CLR_RT_ExecutionEngine.m_cctorThread);
@@ -345,13 +348,11 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::Load___STATIC__SystemR
NANOCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER);
}
}
- else
- {
+
// get assembly index from the eval stack
idx.Set(stack.m_evalStack[1].NumericByRef().u4);
assm = g_CLR_RT_TypeSystem.m_assemblies[idx.Assembly() - 1];
- }
while (eventResult)
{
@@ -379,14 +380,11 @@ HRESULT Library_corlib_native_System_Reflection_Assembly::Load___STATIC__SystemR
// pop timeout heap block from stack
stack.PopValue();
- if (assm->m_flags & CLR_RT_Assembly::StaticConstructorsExecuted)
- {
NANOCLR_CHECK_HRESULT(
g_CLR_RT_ExecutionEngine.NewObjectFromIndex(stack.PushValue(), g_CLR_RT_WellKnownTypes.m_Assembly));
hbObj = stack.TopValue().Dereference();
hbObj->SetReflection(idx);
- }
NANOCLR_CLEANUP();
