thorium-cfx / mono_v2_get_started

Mono v2 runtime for FiveM/RedM
35 stars 1 forks source link

The type initializer for 'CitizenFX.Core.Native.MemoryAccess' threw an exception #4

Closed Marky-S closed 1 year ago

Marky-S commented 1 year ago

Performing this code:

[Command("testmodel")]
private void OnTestModelCommand(byte source, object[] args, string raw)
{
    new Model("mp_m_freemode_01");
}

will throw this exception:

SCRIPT ERROR in handling function reference: client.Player.DebugCommands.ConsoleCommands.OnTestModelCommand
with arguments: (System.Byte, System.Object[], System.String): System.TypeInitializationException: The type initializer for 'CitizenFX.Core.Native.MemoryAccess' threw an exception.
   at CitizenFX.FiveM.Game.GenerateHash (System.String input) [0x0000a] in C:\gl\builds\master\fivem\code\client\clrcore-v2\Client\FiveM\v1\Game.cs:736 
   at CitizenFX.FiveM.Model..ctor (System.String name) [0x00000] in C:\gl\builds\master\fivem\code\client\clrcore-v2\Client\FiveM\v1\Model.cs:36 
   at client.Player.DebugCommands.ConsoleCommands.OnTestModelCommand (System.Byte source, System.Object[] args, System.String raw) [0x0000c] in <7e2eb3cc883049f59599779af5b921e4>:0 
   at (wrapper dynamic-method) System.Object:client.Player.DebugCommands.ConsoleCommands.OnTestModelCommand (object,CitizenFX.Core.Remote,object[])
   at CitizenFX.Core.ReferenceFunctionManager.Invoke (System.Int32 reference, System.Byte* arguments, System.UInt32 argsSize) [0x00024] in C:\gl\builds\master\fivem\code\client\clrcore-v2\Interop\ReferenceFunctionManager.cs:175 

I also checked my CitizenFX.FiveM.Native.dll in resource, its already added. Looks like some kind of bug

thorium-cfx commented 1 year ago

Will be fixed in the next bug-fix update.

Btw, you can just use int as the first parameter, it'll convert primitives for you ;)