TypeInitializationException when used with Costura.Fody
See original GitHub issueHi,
I’m using OpenGL.Net for an app I’m working on, and would like to embed its dependencies as resources with Costura.Fody to simplify deployment. However, OpenGL.Net fails to initialize a context when it’s embedded like this, failing with the following error message:
My FodyWeavers.xml file is simple:
<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
<Costura>
<IncludeAssemblies>
OpenGL.Net
OpenGL.Net.WinForms
</IncludeAssemblies>
</Costura>
</Weavers>
I’m using OpenGL.Net and OpenGL.Net.WinForms, both v0.5.2.
The issue appears to be this line, where Assembly.GetAssembly(typeof(Egl)).Location
is an empty path when embedded, causing Path.GetDirectoryName
to fail with the error above.
Since that code is related to ANGLE stuff, which may be tricky to do nicely when embedded, a simple solution would seem to be to fall back on Directory.GetCurrentDirectory()
for assemblyPath
, or simply short-circuit that block of code entirely.
I’m not sure which option would be preferred, but I would be happy to submit a PR for whatever should be done (this issue is a bit of a show-stopper for me 😀).
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Thanks!
I had a chance to try it out today, and it looks like it’s still not working. If I’m not mistaken,
GetAssemblyLocation
should look more like this:…as it was
Assembly.Location
returning the empty path causingPath.GetDirectoryName
to fail.Ops. I completely missed it! Sorry. Just fixed.