System.ArgumentException: Parameter is not valid. Issue Staging SVG Files (MVC v13.0.78)

kentico guy asked on January 19, 2023 19:41

I'm having an issue staging SVG files in MVC v13.0.78 where I get the following exception trying to stage SVG files only. Looks like it's related to the System.Drawing.BitMap class. This hasn't been modified at all so I'm wondering if anyone has seen this or has ideas about how to fix it.

Also, I can upload the same SVG file fine if I upload it directly to the receiving server, but I can't stage it. PNG files are staging fine. Ideas here?

Message: Parameter is not valid.

Exception type: System.ArgumentException Stack trace: at System.Drawing.Bitmap..ctor(Stream stream) at CMS.Helpers.ImageHelper.GetImage(String filename) at CMS.MediaLibrary.MediaFileInfoProvider.SetMediaFileInfoInternal(MediaFileInfo mediaFile, Boolean saveFileToDisk, Int32 userId, Boolean ensureUniqueFileName) at CMS.MediaLibrary.MediaFileInfoProvider.Set(MediaFileInfo info) at CMS.Synchronization.SyncManager.UpdateObject(GeneralizedInfo& infoObj, DataSet ds, TranslationHelper th, Boolean updateChildren, DataSet binaryData, Boolean addToSite, List1 postProcessList) at CMS.Synchronization.SyncManager.UpdateObject[TInfo](TInfo& infoObj, DataSet ds, TranslationHelper th, Boolean updateChildren, DataSet binaryData, Boolean addToSite, List1 postProcessList) at CMS.Synchronization.SyncManager.UpdateObjects(BaseInfo infoObj, DataSet ds, TranslationHelper th, Boolean updateChildren, DataSet binaryData, Boolean addToSite, Boolean logTasks) at CMS.Synchronization.SyncManager.ProcessTaskInternal(StagingTaskData stagingTaskData, Boolean processChildren, StagingSynchronizationHandler handler) at CMS.Synchronization.WSE3.SyncServer.ProcessSynchronizationTaskInternal(StagingTaskData stagingTaskData)

Recent Answers


Juraj Ondrus answered on January 23, 2023 10:53 (last edited on February 3, 2023 11:59)

This particular file extension is a specific one and it requires additional configuration, depending on your exact environment. For example, can you please check and confirm that you added this extension to allow file extension in the target environment?

UPDATE: the CMSImageExtensions web.config key shall not contain the SVG or WEBP extension - otherwise Kentico tries to apply some image processing on these and since they are not supported, staging will fail with the error. The solution is not to use this key.
For example:

...
< staticContent >  
< remove fileExtension=".svg"/ >  
< mimeMap fileExtension=".svg" mimeType="image/svg+xml" />  
</staticContent>
...
  • the Settings application, in Content -> Media category, into the "Media file allowed extensions" field
  • the Settings application, in the System -> Files category, into the "Upload extensions" field

You may also need to add SVG support on IIS to each site as described here.

1 votesVote for this answer Mark as a Correct answer

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