Michael
Michael

Reputation: 157

using accessor function

I'm trying to successfully decompile and update an old unity game I have, I've fixed most of the errors, but this one is still giving me grief. All the documentation I can find tells me to assign to the member directly, but that isn't an option, as the member set_SurrogateSelector acesses an internal member, m_surrogates.

private static void Init()
{
    UnityLogWriter.Init();
    if (Application.platform.ToString().Contains("WebPlayer"))
    {
        BinaryFormatter.set_SurrogateSelector(new UnitySurrogateSelector());
    }
}


// Decompiled BinaryFormatter
...
internal ISurrogateSelector m_surrogates;
public void set_SurrogateSelector(ISurrogateSelector value)
{
    this.m_surrogates = value;
}

And so, how can I set the surrogate selector? Or do I have to compile a custom mscorlib.dll as well?

EDIT: Updated code, same error

BinaryFormatter nBFormatter = new BinaryFormatter();
UnityLogWriter.Init();
if (Application.platform.ToString().Contains("WebPlayer"))
{
      nBFormatter.SurrogateSelector = new UnitySurrogateSelector();
}

Upvotes: 1

Views: 285

Answers (2)

leppie
leppie

Reputation: 117220

That's not true. BinaryFormatter.SurrogateSelector is public.

But you seem to use it wrong.

It is an instance property, and thus needs an instance.

Upvotes: 1

SLaks
SLaks

Reputation: 887315

That's a property.

BinaryFormatter.SurrogateSelector = new UnitySurrogateSelector();

Upvotes: 1

Related Questions