xpnteam / xpnet

Develop X-Plane plugins in .NET.
MIT License
50 stars 15 forks source link

Can't run more than 1 plugin at a time #33

Open jfjoubert opened 3 years ago

jfjoubert commented 3 years ago

Hi, I have created 2 separate xpnet plugins that are both working fine if it's the only xpnet type plugin added to the xplane plugins folder. The moment I have more than 1 xpnet plugin in the plugins folder then xplane will just hang when trying to load the second xpnet plugin.

The PluginAssemblyName and PluginType entries are unique for both plugins as well as the underlying dll files. What am I doing wrong?

Thanks, Jean

wegylexy commented 3 years ago

I wonder if CLR can be initialized multiple times and run side-by-side. Would you consider native AOT?

jfjoubert commented 3 years ago

Hi, I'm not at all familiar with AOT. I was just wondering how it will work if I need to create more than one plugin. I will probably have to dust off my C++ books and just create native plugins.

wegylexy commented 3 years ago

Simply use https://github.com/wegylexy/XPLM for native AOT. Or would you consider combining the two into one?

jfjoubert commented 3 years ago

Thanks, I will have a look at this.

On Tue, 10 Aug 2021 at 04:07, TimTim @.***> wrote:

Simply use https://github.com/wegylexy/XPLM for native AOT. Or would you consider combining the two into one?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/xpnteam/xpnet/issues/33#issuecomment-895672644, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGGMDZKLT3TKUDF3FTF2VALT4CCWVANCNFSM456WHDDQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

jfjoubert commented 3 years ago

Hi, is there a sample plugin using the XPLM project? I managed to get everything compiled but I'm not sure where the win.xpl is built from. Any help would be greatly appreciated.

wegylexy commented 3 years ago

@jfjoubert A template is available at https://github.com/wegylexy/XPLM/tree/main/XPL , which references 2 nuget packages that will generate win.xpl automatically after native AOT when you publish for win-x64.

jfjoubert commented 3 years ago

Hi, thanks for the info. My XPL project is complaining about the 2 nuget packages... FlyByWireless.XPLM and Microsoft.DotNet.ILCompiler. It seems as though Nuget can't find the Microsoft.DotNet.ILCompiler package. Img001 Img002

Any ideas?

wegylexy commented 3 years ago

Follow https://github.com/dotnet/runtimelab/blob/feature/NativeAOT/docs/using-nativeaot/compiling.md to acquire the experimental ILCompiler.

You do not need my XPLM source code; just reference the 2 nuget packages in your own project.

jfjoubert commented 3 years ago

Thanks for your assistance.

wegylexy commented 3 years ago

Feel free to create a PR to my repo with a guide for new users.

jfjoubert commented 3 years ago

@wegylexy Hi, I'm not having any luck getting this to work. I tried with VS2019 and installed the .NET 6.0 framework. I then tried with VS2022 preview and I'm getting the same errors when trying to publish. I'm using the 'dotnet publish -r win-x64 -c Release' command.

I'm getting a whole bunch of errors: XplTemplate.obj : error LNK2001: unresolved external symbol BCryptGenRandom Runtime.lib(do_vxsort_avx2.cpp.obj) : error LNK2001: unresolved external symbol memset ...and a lot more like these. And eventually, I get some error like this: D:\Windows Kits\10\lib\10.0.20348.0\um\x86\advapi32.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'

I don't know how to reference the x64 instead of x86 libraries.

The project is building successfully though. I'm referencing FlyByWireless.XPLM (1.0.3-alpha) and Microsoft.DotNet.ILCompiler (6.0.0-rc.1.21411.3)

Any pointers would be greatly appreciated.

wegylexy commented 3 years ago

You must run dotnet publish -r win-x64 -c Release in a x64 command prompt to link the correct x64 native libs, with the proper Windows SDKs and Visual C++ x64 build tools installed.

jfjoubert commented 3 years ago

Thanks, I never even thought about that. Now it's working.

jfjoubert commented 3 years ago

Do you perhaps have a sample of how a FlightLoop is registered? Thanks.

wegylexy commented 3 years ago

Added just now https://github.com/wegylexy/XPLM/commit/b9a8ed8ac8138d14af2209091cfcbe890053cbd4

jfjoubert commented 3 years ago

Thanks a million.