With Dotnet's Blazor opening up a number of possibilities I wanted to give it a shot working with Web Assembly and ImGui's C++ library (an easy and convent GUI library). There is a DotNet wrapper that allows for the use of native functionality that I can use in NetCore 6.
Part of what needs to be done with the wrapper is that you need to include a precompiled DLL to allow it to render and take advantage of the library. This is where the problem happens...
Issue
I'm unable to add the DLL as a referenced item when doing a compiled run, though it has been added and referenced in the project.
How it was added
<ItemGroup>
<Content Include="$(ProjectDir)/../deps/cimgui/win-x86/cimgui.dll" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(ProjectDir)/../deps/cimgui/osx-universal/cimgui.dylib" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(ProjectDir)/../deps/cimgui/linux-x64/cimgui.so" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<Reference Include="cimgui">
<HintPath>../deps/cimgui/win-x64/cimgui.dll</HintPath>
</Reference>
</ItemGroup>
Error on Console
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: cimgui
System.DllNotFoundException: cimgui
at ImGuiNET.ImGui.Text(String fmt)
at Hadur.Frontend.Pages.Index.StartUp() in C:\Projects\Hadur\frontend\Hadur.Frontend\Pages\Index.razor:line 20
at Hadur.Frontend.Pages.Index.OnInitializedAsync() in C:\Projects\Hadur\frontend\Hadur.Frontend\Pages\Index.razor:line 28
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
So looking in I found that seemingly Blazor isnt adding the referenced dll this to the proper folder when doing a debug or publish. I looked under \bin\Debug\net6.0\
and saw the cimgui.dll
was added but there is also a wwwroot/_framework
where the dll is missing which makes me wonder why this isnt working and if this is a bug in Blazor.
I also saw that in blazor.boot.json
the dll doesnt seem to be referenced either and I dont know if this is an issue or not.