Fixing error on loading critera for visitor group after changing namespace
Sometimes you need to move code and with that change the namespace for a class.
If you do it for a content type there should be no problem at all since Episerver will update it as long as you have specified a GUID for the content type, and that is something we always do, right.... ;-)
For some other part of the code it is a little bit harder since it will not be fixed by Episerver and one of these things is if you have created your own Visitor Group Criterion. The reason for that is that Episerver has saved information about the namespace in the database inside the BigTable.
There is a way to fix this and that Episerver have a SQL View that it use to talk to the database about Visitor Group Criterion that is named: "VisitorGroupCriterion" and we can use this ourself to fix the namespace.
So to fix this you need to write an SQL-statement that looks like this (You need to change the part OLDNAMESPACE, NEWNAMESPACE, OLDASSEMBLYNAME and NEWASSEMBLYNAME to your own info).
Update VW_VisitorGroupCriterion
Set TypeName = 'NEWNAMESPACE.CustomCriterion, NEWASSEMBLYNAME'
Where TypeName = 'OLDNAMESPACE.CustomCriterion, OLDASSEMBLYNAME'
After you have done this you need to recycle the application pool or in any other way make Episerver release all it´s cache and will need to update from the database again.
If you get an error saying that the database can not find VW_VisitorGroupCriterion it means that the criterion has not been used so it should not be any problem.
Disclaimer: You should not be updating information inside the Episerver Database if you do not know what you are doing. I give you this tip because it worked for me and if you do it, be sure to take a backup of the database first and run it with care!
Comments