title: Is it possible to set the default Serializer to a pre-compiled one in protobuf-net?
body: <p>I am using protobuf-net with protobuf-net.grpc and am attempting to get it to work on Xmarin/Ios.</p>
  <p>Currently I have attempted to create a pre-compiled serializer:</p>
  <pre><code>            RuntimeTypeModel runtimeTypeModel = RuntimeTypeModel.Create();
              runtimeTypeModel.AllowParseableTypes = true;
              runtimeTypeModel.AutoAddMissingTypes = true;
              runtimeTypeModel.AutoCompile = false;
              runtimeTypeModel.Add(typeof(UserInfo), true);
              Directory.SetCurrentDirectory(@&quot;..\..\&quot;);
              runtimeTypeModel.Compile(&quot;PDASerializers&quot;, @&quot;PDASerializers.dll&quot;);
  </code></pre>
  <p>When i reference this .dll and do <code>new PDASerializers().Serialize(new UserInfo())</code> it works without issues.</p>
  <p>I am however walking into a brick wall when attempting to go all in into awesomeness and use <code>protobuf-net.grpc</code>.</p>
  <p>The issue is that as soon as I call: <code>channel.CreateGrpcService&lt;ISomeInterface&gt;</code> I get a reflection.emit error:</p>
  <pre><code>Operation is not supported on this platform.
  
    at System.Reflection.Emit.AssemblyBuilder.DefineDynamicAssembly (System.Reflection.AssemblyName name, System.Reflection.Emit.AssemblyBuilderAccess access) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.pns.cs:129 
    at ProtoBuf.Grpc.Internal.ProxyEmitter..cctor () [0x0001e] in /_/src/protobuf-net.Grpc/Internal/ProxyEmitter.cs:18 
  </code></pre>
  <p>nb.</p>
  <p>I read at various places turning off &quot;AutoCompile&quot; could be a work around. This did solve me nog begin able to call Serialize directly - so it would seem I have no need for a pre-compiled serializer.</p>
  <p>After some digging into the inner workings of protobuf I attempted to do this:</p>
  <pre><code>typeof(TypeModel).GetMethod(&quot;SetDefaultModel&quot;, BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, new object[] { new PDASerializers() })
  </code></pre>
  <p>But regretfully this also did not solve the issue.</p>
  <hr />
  <p>Concretely my question is as follows;</p>
  <p>Is it possible to either replace the default serializer to use the pre-compiled one in protobuf-net.grpc or is there some other way to turn off &quot;AutoCompile&quot; <em>globally</em> (so also for protobuf-net.grpc)?</p>