• Publisert
  • 1 min

Using PlugInSettings in virtual roles at application startup

Using PlugInSettings for virtual role registration on application startup gave me errors when deploying to test, so I had to find another solution.

I was setting up a virtual role that required some configuration values coming from PlugInSettings. When deploying to test, all I got was a YSOD telling me that PlugInSettings was null - ending up in EPiServer.DataAccess somewhere. It worked on my development environment, but as it crashed elsewhere it seemed like it working locally was merely luck. And such accidental mechanisms that work sometimes are scary.

Since this didn't seem like a very robust approach, I couldn't be bothered to find out exactly why it crashed. I'd rather spend time finding a different solution.

The solution was to use an IInitializableModule with a ModuleDependency attached to it, and then rewire the mentioned virtual role every time the settings changed.