Improbable Icon

C# API problem



When playing around with the csharp API I ran into an issue when trying to assign Components to Entities.

Namely: An exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in Improbable.WorkerSdkCsharp.dll but was not handled in user code

So I did what any sensible person would do and decompiled the Improbable.WorkerSdkCsharp.dll

The problem is that the code generated from the schema isn’t necessarily loaded as an assembly when the lookup table for components is generated by the static constructor of the CompnentDatabase type in WorkerSdkCsharp.Internal.

As a workaround explicitly loading the GeneratedCode assembly into the current AppDomain works, but I think it would be a cleaner solution to hook the CurrentDomain.AssemblyLoad event to add to the lookup table when new assemblies are loaded after it is first generated.

Feel free to move this topic somewhere else if more appropriate, this just seemed like the most fitting forum I have access to.

Best regards,
Nils Ole Timm


Hi @funkinperson,

As you pointed out, the workaround is to explicitly load the generated code assemblies via Assembly.Load.

Thank you for the CurrentDomain.AssemblyLoad suggestion. We will investigate it.

Best regards,