-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not working with native aot: Common Language Runtime detected an invalid program #12
Comments
AOT is currently not supported. Lease see #11 for more details. |
I'm working on a new verion that is compatible with AOT. It will take a few days. |
@ivanjx Have a look to the version v5.0.0-pre. Native AOT should work with this version. Please give me feedback so that I can make the pre-release to a release. |
thanks a lot @MartinKuschnik the latest pre release version works perfectly in my case! |
one more thing is it possible to compile the cpp wrapper as a static library so it wont output a dll similar to this AvaloniaUI/Avalonia#9503 |
"Static library" means that the library is going to be merged with your final application. This concept doesn't exist in .net. .net supports DLLs only. Maybe there's a way by using C++ CLI but this would require more work - sorry. |
the concept does not exists with .net but it does exist with .NET Native AOT. |
Ok, your application that gets compiled to native code could link statically. Why it is so important for you to have only a single file? |
easier deployment. also to make sure the dependency will always be there and cannot be easily altered. |
I can add the static lib but does not know how to link it in the project file without using absolute paths. |
im fine with just be able to compile it myself like i did with skiasharp |
thanks a lot. i will try it in a few hours. |
For me worked: <ItemGroup>
<!-- Generate direct PInvokes for Dependency -->
<DirectPInvoke Include="WmiLight.Native.dll" />
<!-- Specify library to link against -->
<NativeLibrary Include="wbemuuid.lib" Condition="$(RuntimeIdentifier.StartsWith('win'))" />
<NativeLibrary Include="path to x64 WmiLight.Native.lib " Condition="$(RuntimeIdentifier.StartsWith('win'))" />
</ItemGroup> |
The following works also for me but does not require absolute paths. <ItemGroup>
<!-- Generate direct PInvokes for Dependency -->
<DirectPInvoke Include="WmiLight.Native.dll" />
<!-- Specify library to link against -->
<NativeLibrary Include="wbemuuid.lib" Condition="$(RuntimeIdentifier.StartsWith('win'))" />
<NativeLibrary Include="$(OutputPath)WmiLight.Native.lib" Condition="$(RuntimeIdentifier.StartsWith('win'))" />
</ItemGroup> The problem with this solution: the .lib files will be copies to the output directory. This is confusing to all other users of the library. Would it be fine for you if i would locate the .lib files into an other directory. Than you would need to reference to the nuget directory. |
@ivanjx Works for you? |
sorry i was tasked with different projects. i have tried your new nuget but it does not seem to copy the lib files into the directory. i grabbed the .lib files manually and it seemed to work but i am still missing the EDIT: |
also for the .lib files there is a warning:
which can be fixed by following this (i dont know how to do it with just command line yet):
|
@ivanjx Try Version 5.0.2-pre |
@ivanjx Try directly Version 5.1.0 |
@MartinKuschnik thanks! now the warnings are gone. though i still not able to use this |
Nice! To use |
it is okay not to include the .lib at all as long as there is an easy way to compile it myself or just download it. |
@ivanjx Please have a look to Version 5.1.1 and Native AOT deployment. You should be able to replace <!-- Generate direct PInvokes for Dependency -->
<DirectPInvoke Include="WmiLight.Native.dll" />
<!-- Specify library to link against -->
<NativeLibrary Include="wbemuuid.lib" Condition="$(RuntimeIdentifier.StartsWith('win'))" />
<NativeLibrary Include="path to x64 WmiLight.Native.lib " Condition="$(RuntimeIdentifier.StartsWith('win'))" /> with <PublishWmiLightStaticallyLinked>true</PublishWmiLightStaticallyLinked> |
@MartinKuschnik just tried and it works well. thanks. |
my code:
the error:
csproj:
The text was updated successfully, but these errors were encountered: