yes, it seems that DX fills textures with valid memory to avoid access violations when the texture is missing. For the rest, I am sorry, but I have no experience enough with SetTexture. It sounds pretty strange though.

Have you tried to check the return value of the method? It may throw some light over the issue. Anyway, the code is so tiny that there is no room for improvements. All the pointers are set by the engine and the event calls a single function only: the very same function that the engine uses to set the textures of the entities, but it is failing... assured headache.

You can use SetTexture out of an event, but no in this case. Each effect loaded in the graphic card has a static memory table associated and is modified for each entity rendered with it. The role of material events is, precisely, to be able to modify an already opened rendering process for each entity.

As a workaround, the use of atlas maps might help. At the end, the textures are normaly related by groups.