MediaFileInfoProvider.GetMediaFileInfo gives StackoverflowException.

Jelle Capenberghs asked on July 31, 2019 14:21


In the controller of my widget I have the id (guid) of a file in the media library. I want to have the URL of the file so I use MediaFileInfoProvider.GetMediaFileInfo(guid, sitename). The sitename is "DancingGoatMvc" in my example. But every time I use that method, there is a stackoverflowexception and my whole website and iis express shuts down. Since the MediaFileInfoProvider is used in the documentation, I would expect it to work? I use Kentico 12 with Service Pack in MVC.

Am I doing someting wrong or is there a bug in the GetMediaFileInfo method? Other methods of the MediaFileInfoProvider (for example MediaFileInfoProvider.GetMediaFiles()) work correctly.

Correct Answer

Jelle Capenberghs answered on July 31, 2019 15:16

I found the solution. The file id I was passing to the GetMediaFileInfo was a dynamic type and not a typed Guid. That was causing the exception. When I give the typed Guid to the method, it works fine!

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.