Has anyone faced this exception and how to fix it?
Exception thrown: System.TypeInitializationException: The type initializer for 'Skyline.Protocol.PowerShellApi.Commands.CommandMapper' threw an exception. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.RuntimeModule.GetTypes() at System.Reflection.Assembly.GetTypes() at Skyline.Protocol.PowerShellApi.Commands.CommandMapper..cctor() --- End of inner exception stack trace --- at Skyline.Protocol.PowerShellApi.Commands.CommandMapper.GetMappedCommands() at Skyline.Protocol.ProtocolApi.Controllers.CommandsConfigurationController.OnInitialization(SLProtocol protocol) at QAction.Run(SLProtocol protocol)
This happened after the Nuget migration.
I tried to catch System.Reflection.ReflectionTypeLoadException exception, but without success.
The connector throws this exception because it uses the GetTypes method to obtain information about the loaded assemblies in the application domain.
The documentation of this method states the following:
If the GetTypes method is called on an assembly and a type in that assembly is dependent on a type in an assembly that has not been loaded (for example, if it derives from a type in the second assembly), a ReflectionTypeLoadException is thrown. For example, this can happen if the first assembly was loaded with the ReflectionOnlyLoad or ReflectionOnlyLoadFrom methods, and the second assembly was not loaded. It can also happen with assemblies loaded using the Load and LoadFile methods if the second assembly cannot be located when the GetTypes method is called.
Can you verify if you need to iterate over all assemblies in the application domain or if it's sufficient to only apply reflection on a specific assembly?
These errors sometimes happened in our environments and fixed by the following operation.
- Stop DataMiner
- Remove Skyline DataMiner\Scripts\*.txf files
- Remove all file in Skyline DataMiner\Scripts\Compiled folder
- Start DataMiner
I hope these solve your issues.