javisar / ONI-Modloader

A modloader for Oxygen Not Included
MIT License
72 stars 25 forks source link

Double mod crashes the game. #37

Closed rainbowdesign closed 5 years ago

rainbowdesign commented 5 years ago

Having the same mod two times crashes the game. I think that is not good, better would be to either: Have them run parallel or skip the second.

javisar commented 5 years ago

Do you mean the same mod with the same filename? Can you attach the file structure you have. Please, always attach the log file.

rainbowdesign commented 5 years ago

I rechecked it its a little different: The game does not crash but it still seems the mods are not loaded correctly. Take a mod copy it leave it in the modfolder with a different name gives that error: [= INFO =] Loading AutoSweeperMod, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null [= INFO =] Loading BuildingPatches, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null [= INFO =] Loading AutoSweeperMod, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null [= INFO =] Loading NuclearPowerMod, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: element already exists at System.Collections.Generic.SortedList2[System.String,ModLoader.DependencyGraph+Vertex].PutImpl (System.String key, ModLoader.Vertex value, Boolean overwrite) [0x00000] in <filename unknown>:0 at System.Collections.Generic.SortedList2[System.String,ModLoader.DependencyGraph+Vertex].Add (System.String key, ModLoader.Vertex value) [0x00000] in :0 at ModLoader.DependencyGraph.TopologicalSort () [0x00000] in :0 at ModLoader.ModLoader.Start () [0x00000] in :0 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 --- End of inner exception stack trace --- at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in :0 at ModDB.StartModLoader () [0x00000] in :0 Failed to use ModLoader. Using built in mod system instead.

javisar commented 5 years ago

I've added a simple check to skip duplicate mods (same assembly name). Find it here: https://github.com/javisar/ONI-Modloader/blob/master/Managed/ModLoader.dll

javisar commented 5 years ago

@rainbowdesign could you check if it is already fixed?

rainbowdesign commented 5 years ago

got this now:

System.BadImageFormatException: Could not load file or assembly 'D:/Steam/steamapps/common/OxygenNotIncluded/OxygenNotIncluded_Data\Managed/ModLoader.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. File name: 'D:/Steam/steamapps/common/OxygenNotIncluded/OxygenNotIncluded_Data\Managed/ModLoader.dll' at (wrapper managed-to-native) System.Reflection.Assembly:LoadFrom (string,bool) at System.Reflection.Assembly.LoadFrom (System.String assemblyFile, System.Security.Policy.Evidence securityEvidence) [0x00000] in :0 at System.Reflection.Assembly.LoadFile (System.String path, System.Security.Policy.Evidence securityEvidence) [0x00000] in :0 at System.Reflection.Assembly.LoadFile (System.String path) [0x00000] in :0 at ModDB.StartModLoader () [0x00000] in :0 Failed to use ModLoader. Using built in mod system instead.

javisar commented 5 years ago

Mmmm, pretty weird. Can you download it again, it seems that you have a corrupted version of the file. The file size is 11776 bytes.

rainbowdesign commented 5 years ago

I checked it again and i think it does work.