Skip to content
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

NativeAOT not supported #8

Closed
kant2002 opened this issue May 29, 2021 · 2 comments
Closed

NativeAOT not supported #8

kant2002 opened this issue May 29, 2021 · 2 comments

Comments

@kant2002
Copy link

kant2002 commented May 29, 2021

I found this excellent library, and decide play with it in NativeAOT.
Since this is thin wrapper agains Win32 API, I thought that it will just work.

Unfortunately I hit this line

moduleInstance ??= new ModuleInstance(Marshal.GetHINSTANCE(Assembly.GetCallingAssembly().Modules.First()));

Assembly.GetCallingAssembly() does not supported by NativeAOT.
Is there a way how code could be modified to better accomodate NativeAOT

I make run Clock sample with reflection disabled, by passing HINSTANCE of exe. Maybe you could find a better way.

// This was added.
public Clock()
    : base(moduleInstance: Modules.GetModuleHandle(null))
{
}

BTW: only 1.3 Mb resulting executable.

@JeremyKuhne
Copy link
Owner

@kant2002 Sorry about the delayed response. Here is the change I made: a95a94d

@kant2002
Copy link
Author

No problem. Your library has very interesting properties, and so close to Win32. Thanks for pinging me. Let me try it out

@kant2002 kant2002 closed this as completed Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants