gisinternals / buildsystem

Build system on www.gisinternals.com
MIT License
35 stars 10 forks source link

Dll Not Found When Compiling C# Project Self-Contained #220

Closed Mbucari closed 11 months ago

Mbucari commented 1 year ago

When compiling the C# project Self-Contained, GdalConfiguration throws DllNotFoundException for gdal-wrap.dll. I've traced the problem to the following line in the GdalConfiguration static constructor:

string executingAssemblyFile = new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath;

The problem is that AssemblyName.CodeBase is null for Self-Contained applications. See error code IL3000.

As an alternative, Microsoft recommends using System.AppContext.BaseDirectory. Alternatively you may use Environment.ProcessPath.

szekerest commented 11 months ago

This issue is applied to the single file assemblies. Fixed in the 3.7.3 nuget packages