mooege/mooege — Issue #410: non-LazyLoading broken
Author: Nuk3R4z0r
Created: 2012-01-23 19:36:19+00:00
State: open

Ok so setting LazyLoading to false gives this exception:

[Exception] System.TypeInitializationException: The type initializer for 'Mooege.Common.MPQ.MPQStorage' threw an exception. ---> System.AggregateException: One or more errors occurred. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DivideByZeroException: Attempted to divide by zero.
at CrystalMpq.MpqFileStream..ctor(MpqFile file, Stream baseStream)
at Mooege.Common.MPQ.FileFormats.World..ctor(MpqFile file)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct& signature, RuntimeType declaringType)
at System.RuntimeMethodHandle.InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct signature, RuntimeType declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at Mooege.Common.MPQ.MPQAsset.RunParser()
at Mooege.Common.MPQ.Data.<>c__DisplayClass3.b__1()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout)
at System.Threading.Tasks.Task.WaitAll(Task[] tasks)
at Mooege.Common.MPQ.Data.LoadCatalog(String fileName, Boolean useBaseMPQ, List`1 groupsToLoad)
at Mooege.Common.MPQ.Data.LoadCatalogs()
at Mooege.Common.MPQ.Data.Init()
at Mooege.Common.MPQ.MPQStorage..cctor()
--- End of inner exception stack trace ---
at Mooege.Common.MPQ.MPQStorage.get_Initialized()
at Mooege.Program.Main(String[] args)

Also I noticed wrapping a "if (_data != null)" around:

Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
_data = (FileFormat)Activator.CreateInstance(Parser, new object[] { MpqFile });
PersistenceManager.LoadPartial(_data, SNOId.ToString());

fixes this problem and speeds up the loading exceptionally but gives some ItemGenerator problems further on.
Hope this helps, keep up the good work!