pedr0fontoura/fivem-appearance

Exports do not working in a C# project

JLFSL opened this issue · 1 comments

JLFSL commented

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

To anyone having the same issue. Make sure you call it on the Client namespace as so: citizenfx/fivem#1742 (comment)