MediaCreatorOptions.KeepExisting is gone in Sitecore 9

I have a module I’ve been working on that sets the MediaCreatorOptions.KeepExisting setting to false. This module has several different versions for different versions of Sitecore, so there is always a version of it that works in any Sitecore version. In the master branch of the code repository we had version 8.1 (initial release) of Sitecore.Kernel.dll in the references. This has led to an interesting revelation regarding this KeepExisting property.

In Sitecore 8.1 Update 2 (rev. 160302), Sitecore deprecated KeepExisting but it could still be used in code. Instead, you were asked to use OverwriteExisting. When our module ran on this version or later (up to the final revision of 8.2), no errors occurred so we were oblivious to anything being wrong. Since our solution had 8.1 initial release DLLs referenced, we did not see a warning in Visual Studio.

Anyway, KeepExisting was still allowed all the way until Sitecore 9.0 (initial release) when they removed the property altogether. So when we began testing our module in Sitecore 9, we noticed this error:

Method not found: 'Void Sitecore.Resources.Media.MediaCreatorOptions.set_KeepExisting(Boolean)'.

So, the message is: If you have a module that uses KeepExisting, you’ll need to create a new release of it for Sitecore 9 and swap that out with OverwriteExisting. I had to do a lot of digging through the Sitecore.Kernel.dll file for each Sitecore version to find out when this was property was deprecated and when it was initially removed. Unfortunately, Sitecore did not include any of this information in their release notes / breaking changes. Boo!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s