Duplicating a level in c++ crashes in Game mode but works fine with Editor build

I wanted to try duplicating a Ulevel and it seems to work fine in the editor build configuration in visual studio. But running the same thing in the game build configuration crashes the .exe . Has anyone already tried this or is there a better way to do it.
i am using StaticDuplicateObject function to duplicate the ULevel.