[C# & Lua] Having a lot of problems with exports


Sooo, I’m trying to use exports to call lua functions using C#, but I keep getting an error saying that the export doesn’t exist in the dictionary. The lua and C# files are in the same resource, so I don’t know if that’s a factor that prevents me calling the exports.

Here is my code:

Server C#:

var res = new ExportDictionary()[API.GetCurrentResourceName()].httpRequest("https://google.com/",
    "GET", new Dictionary<string, string>(), new Dictionary<string, string>());


function httpRequest(url, method, data, headers)
    local debug = config.debug
    local data = nil
    PerformHttpRequest(url, function(status, text, headers)
        data = {
            status = status,
            content = text,
            headers = headers
    end, method, json.encode(data, headers))
    while data == nil do
    return data


server_script 'server.lua'
export 'httpRequest'

server_script 'server.net.dll'

C# error:

Exception thrown by a task: System.AggregateException: One or more errors occurred. ---> Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'CitizenFX.Core.ExportSet' does not contain a definition for 'httpRequest'
  at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object,string,string,System.Collections.Generic.Dictionary`2<string, string>,System.Collections.Generic.Dictionary`2<string, string>)
  at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet] (System.Runtime.CompilerServices.CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) [0x00136] in <fe779a58d2d54ffea553ee896d1fee6a>:0
  at (wrapper delegate-invoke) System.Func`7[System.Runtime.CompilerServices.CallSite,System.Object,System.String,System.String,System.Collections.Generic.Dictionary`2[System.String,System.String],System.Collections.Generic.Dictionary`2[System.String,System.String],System.Object]:invoke_TResult_T1_T2_T3_T4_T5_T6 (System.Runtime.CompilerServices.CallSite,object,string,string,System.Collections.Generic.Dictionary`2<string, string>,System.Collections.Generic.Dictionary`2<string, string>)

I cleared cache server and client side and it did nothing to help.
I also referred to other topics on the website and they didn’t help me at all…


server_export? also don’t create ExportDictionary yourself, just use Exports in BaseScript.