pedr0fontoura / fivem-appearance

👀 A flexible player customization script for FiveM.
https://forum.cfx.re/t/release-fivem-appearance/2438537
MIT License
120 stars 72 forks source link

Exports do not working in a C# project #83

Closed JLFSL closed 1 year ago

JLFSL commented 1 year ago

I've been trying to get it to work on my project written in C#, but the exports do not seem to work on C#. Could be a problem in my code or another problem with cfx in general. The exports however do work if I create a resource in lua.

C# code: await Exports["fivem-appearance"].startPlayerCustomization(new Action<object>((appearance) => { Debug.WriteLine(appearance.ToString()); }), config);

The error: MainThrd/ ^1SCRIPT ERROR in task continuation: System.TypeLoadException: Could not resolve type with token 0100000e^7 [ 954391] [b2699_GTAProce] MainThrd/ ^3> void Mono.CSharp.ImportedAssemblyDefinition.ReadAttributes()^7 (^5@Emergency/Mono.CSharp.dll^7 <- /mnt/idfk/meow/mono/mcs/mcs/import.cs:1719) [ 954391] [b2699_GTAProce] MainThrd/ ^3> IAssemblyDefinition Mono.CSharp.MetadataImporter.GetAssemblyDefinition(Assembly assembly)^7 (^5@Emergency/Mono.CSharp.dll^7 <- /mnt/idfk/meow/mono/mcs/mcs/import.cs:972) [ 954391] [b2699_GTAProce] MainThrd/ ^3> void Mono.CSharp.ReflectionImporter.ImportAssembly(Assembly assembly, RootNamespace targetNamespace)^7 (^5@Emergency/Mono.CSharp.dll^7 <- /mnt/idfk/meow/mono/mcs/mcs/reflection.cs:86) [ 954391] [b2699_GTAProce] MainThrd/ ^3> DynamicContext Microsoft.CSharp.RuntimeBinder.DynamicContext.Create()^7 (^5@Emergency/Microsoft.CSharp.dll^7 <- /mnt/idfk/meow/mono/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/DynamicContext.cs:104) [ 954391] [b2699_GTAProce] MainThrd/ ^3> DynamicMetaObject Microsoft.CSharp.RuntimeBinder.CSharpInvokeMemberBinder.FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)^7 (^5@Emergency/Microsoft.CSharp.dll^7 <- /mnt/idfk/meow/mono/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpInvokeMemberBinder.cs:156) [ 954391] [b2699_GTAProce] MainThrd/ ^3> async void Emergency.Client.LocalPlayer.PlayerManager.SpawnAsync()^7 (^5@Emergency/Emergency.Client.net.dll^7 <- C:\fivem\Server\resources\[emergency]\Emergency\Client\LocalPlayer\PlayerManager.cs:45)

JLFSL commented 1 year ago

To anyone having the same issue. Make sure you call it on the Client namespace as so: https://github.com/citizenfx/fivem/issues/1742#issuecomment-1345562464