Cannot return user defined styles by style identifier

Hi,
I use Aspose.Word.dll 14.10.0.0 in our project.
I try to replace som values in header. For this i need to copy words style. But when i try it an error occures as: Cannot return user defined styles by style identifier.
Could you please help me about this error?
note: i attached .doc file and my test project. You can upload document. Use replacement tag as DOC_ADI and Replacement Value as whatever you want. After you can press Get Uploaded File.
Thanks.

Hi Ahmet,

Thanks for your inquiry. Unfortunately, I am unable to execute your code due to DevExpress.Web. I would suggest you please upgrade to the latest version (v14.11.0) from here and let us know how it goes on your side.

If the problem still remains, please create a standalone/runnable simple application (for example a Console Application Project) that demonstrates the code you used to generate your output document and share it here for testing. I will investigate the issue on my side and provide you more information.

Hi Tahir,
I tested the version (v14.11.0) but problem is still remaining.
DevExpress dlls are attached, please check the application.

Hi Ahmet,

Thanks for sharing the detail. Unfortunately, DevExpress dlls do not work at my side due to license issue. However, I have traced the issue in CopyFormatting method. Please use the following modified method of CopyFormatting in your code.

Hope this helps you. Please let us know if you have any more queries.

public static void CopyFormatting(Object source, Object dest)
{
    if (source.GetType() != dest.GetType())
        throw new ArgumentException("All objects must be of the same type");
    foreach (PropertyInfo prop in source.GetType().GetProperties())
    {
        if (prop.Name == "Item" || prop.Name == "Style" || (prop.Name == "StyleIdentifier" && prop.GetValue(source, null).ToString() == "User"))
            continue;
        object value;
        try
        {
            value = prop.GetValue(source, null);
        }
        catch (Exception)
        {
            continue;
        }
        if (value != null)
        {
            if (value.GetType().IsClass && prop.GetGetMethod().ReturnType.Assembly.ManifestModule.Name == "Aspose.Words.dll")
            {
                CopyFormatting(prop.GetValue(source, null), prop.GetValue(dest, null));
            }
            else if (prop.CanWrite)
            {
                prop.SetValue(dest, prop.GetValue(source, null), null);
            }
        }
    }
}