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

Does NativeAOT support COM and COM Server #1

Open
frenchfish opened this issue Dec 13, 2023 · 2 comments
Open

Does NativeAOT support COM and COM Server #1

frenchfish opened this issue Dec 13, 2023 · 2 comments

Comments

@frenchfish
Copy link

Hello do you know how to make Comobject in Native AOT (which will be used in native )

@kant2002
Copy link
Owner

Hi. Currently NativeAOT lacking of support for Com servers. The link https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.comwrappers.getorcreateobjectforcominstance?view=net-8.0 which you gave to me in email, does not the help with createion of COM server.

If you brave enough, you can create DLL where you export nescessary functions 'DllGetClassObject' at minimum and implement IClassFactory you can do the trick.

You can see how it was done in managed profiler.

https://github.com/kevingosse/ManagedDotnetProfiler/blob/master/ManagedDotnetProfiler/DllMain.cs

https://github.com/kevingosse/ManagedDotnetProfiler/blob/master/ProfilerLib/ClassFactory.cs

Be careful, since all marshalling between COM datatypes and .NET datatypes you have to do yourself.

@frenchfish
Copy link
Author

https://github.com/kevingosse/ManagedDotnetProfiler/blob/master/ManagedDotnetProfiler/DllMain.cs

https://github.com/kevingosse/ManagedDotnetProfiler/blob/master/ProfilerLib/ClassFactory.cs

Be careful, since all marshalling between COM datatypes and .NET datatypes you have to do yourself.
Thanks. Great tip

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