title: Using GDAL package in c# .Net core 5 makes Error
body: <p>I've created a .net core 5 web application with visual studio 2019. I've added GDAL Packages to my project. When I run the web application locally there are no problems but when I publish the application on the IIS it makes an error. The Packages that I've added are like below:
  <a href="https://i.stack.imgur.com/CqBru.png" rel="nofollow noreferrer">GDAL Packages</a></p>
  <p>and my code is like this :</p>
  <pre><code>public IActionResult GetLayerInfo(string fileName)
          {
  
              var path = Path.Combine(
                          Directory.GetCurrentDirectory(), @&quot;wwwroot\files\import&quot;,
                          fileName);
  
              List&lt;string&gt; fList = new List&lt;string&gt;();
              GdalConfiguration.ConfigureGdal();
              GdalConfiguration.ConfigureOgr();
  
              Ogr.RegisterAll();
  
              DataSource sDatasource = Ogr.Open(path, 1);
              if (sDatasource == null)
                  return null;
  
              OSGeo.OGR.Layer sLayer = sDatasource.GetLayerByIndex(0);
              FeatureDefn srcVectorDefn = sLayer.GetLayerDefn();
              var type = srcVectorDefn.GetGeomType();
              var geomType = wkbGeometryType.GetName(type);
              var spatialReference = sLayer.GetSpatialRef();
              long fcount = sLayer.GetFeatureCount(1);
              var epsg = spatialReference.GetAttrValue(&quot;AUTHORITY&quot;, 1);
              for (int i = 0; i &lt; srcVectorDefn.GetFieldCount(); i++)
              {
                  FieldDefn fieldDefn = srcVectorDefn.GetFieldDefn(i);
                  fList.Add(fieldDefn.GetName());
              }
              sDatasource.Dispose();
              return Json(new
              {
                  fCount = fcount,
                  epsg = epsg,
                  geomType = geomType.Replace(&quot;wkb&quot;, &quot;&quot;),
                  fList = fList,
                  tName = Path.GetFileNameWithoutExtension(fileName)
              });
          }
  </code></pre>
  <p>and when I publish project in the IIS the error is like this :</p>
  <pre><code>An unhandled exception occurred while processing the request.
  NotSupportedException: Serialization and deserialization of 'System.Type' instances are not supported and should be avoided since they can lead to security issues.
  System.Text.Json.Serialization.Converters.TypeConverter.Write(Utf8JsonWriter writer, Type value, JsonSerializerOptions options)
  
  NotSupportedException: Serialization and deserialization of 'System.Type' instances are not supported and should be avoided since they can lead to security issues. Path: $.error.TargetSite.DeclaringType.
  System.Text.Json.ThrowHelper.ThrowNotSupportedException(ref WriteStack state, NotSupportedException ex)
  </code></pre>
  <p>The Error fired when it reachs this line</p>
  <pre><code>Ogr.RegisterAll();
  
  </code></pre>
  <p>what is the problem ?</p>