Create Xml to string serializer I don't want to serialize everything. I created a custom attribute DoNotSerializeAttribute. If some property in info contain that attribute then ignore it and do not serialize it.

Is my code bug-free? Maybe I can improve it or I miss something?

class Program
{
    static void Main(string[] args)
    {
        var s = Serialize(new BackgroundJobInfo {Text = "toto", BackgroundJob = new BackgroundJob { Password = "pass"}});
        var myJob = Deserialize(s);
    }

    public static string Serialize(BackgroundJobInfo info)
    {
        using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
        {
            var writer = XmlWriter.Create(stringWriter);
            var dataContractSerializer = new DataContractSerializer(typeof(BackgroundJobInfo),
                                                                    null,
                                                                    int.MaxValue,
                                                                    true,
                                                                    true,
                                                                    new MySurrogate());
            dataContractSerializer.WriteObject(writer, info);
            writer.Flush();

            return stringWriter.ToString();
        }
    }

    public static BackgroundJobInfo Deserialize(string info)
    {
        using (var stringReader = new StringReader(info))
        {
            try
            {
                var xmlReader = XmlReader.Create(stringReader);
                var dataContractSerializer = new DataContractSerializer(typeof(BackgroundJobInfo));
                return (BackgroundJobInfo) dataContractSerializer.ReadObject(xmlReader);
            }
            catch (Exception e)
            {
                // hopefully, will never happen
                return null;
            }
        }
    }
}


internal class MySurrogate : IDataContractSurrogate
{
    public Type GetDataContractType(Type type)
    {
        return typeof (BackgroundJobInfo);
    }

    public object GetObjectToSerialize(object obj, Type targetType)
    {
        var maskedProperties = obj.GetType().GetProperties();
        var b = maskedProperties.Where(m =&gt; m.GetCustomAttributes(typeof(DataMemberAttribute), true).Any() &amp;&amp;
                                            m.GetCustomAttributes(typeof(DoNotSerializeAttribute), true).Any());
        foreach (var member in b)
        {
            member.SetValue(obj, null, null);
        }
        return obj;
    }


internal class DoNotSerializeAttribute : Attribute
{
}

[KnownType(typeof(BackgroundJob))]
[DataContract]
public class BackgroundJobInfo
{
    [DataMember(Name = "text")]
    public string Text { get; set; }

    [DataMember(Name = "backgroundJob")]
    public BackgroundJob BackgroundJob { get; set; }
}

[DataContract]
public class BackgroundJob
{
    [DataMember(Name = "password")]
    [DoNotSerializeAttribute]
    public string Password { get; set; }
}
Although you are using the using statement with StringReader and StringWriter both the XmlReader and XmlWriter are implementing IDisposable as well, so the usage of it should be enclosed in a using statement too.  
Catching an exception without doing anything with it is usually bad practice. You should at least log the exception.  
Although you have named your variables and methods well, I am a little bit concerned about the info parameter because it isn't telling anything about what it is.