I’m currently writing the core of my resource using C# (.NET Framework 4.5.2). Everything is more or less going well, but I’m a little stumped on two issues.
MySQL Connector Dependencies
I’m currently using the Connector/Net MySQL reference from the MySQL people. Adding it as a reference to each class library is not a problem. However, once built, I’m confused as to what I need to include with the compiled resource.
Here’s a screenshot of my build folder.
And now, here’s one of the resource folder titled KingfisherCore
.
Now, when I ran the resource the first time, my log outputted an error, looking for, firstly, MySql.Data.dll
, then Google.Protobuf.dll
. I planned to work through it step by step to work out what I needed and what I didn’t, but then the following error appeared in the CitizenFX.log (serverside).
[ 2094] Loaded KingfisherCoreServer.net, Version=1.0.0.0, Culture=neutral, PublicKeyToken=x into ScriptDomain_2068537367
[ 2188] Loaded MySql.Data, Version=8.0.12.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d into ScriptDomain_2068537367
[ 2235] Loaded Google.Protobuf, Version=3.5.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604 into ScriptDomain_2068537367
[ 2641] Exception loading assembly System.Configuration.Install: System.IO.FileNotFoundException: Unable to find the specified file.
[ 2641]
[ 2641] Server stack trace:
[ 2656] at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (System.Int32 errorCode) [0x0000a] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 2656] at (wrapper cominterop) CitizenFX.Core.IScriptHost:OpenHostFile (string)
[ 2656] at (wrapper cominterop-invoke) CitizenFX.Core.IScriptHost:OpenHostFile (string)
[ 2656] at CitizenFX.Core.MonoScriptRuntime+WrapScriptHost.OpenHostFile (System.String fileName) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\MonoScriptRuntime.cs:254
[ 2656] at (wrapper remoting-invoke-with-check) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:OpenHostFile (string)
[ 2656] at (wrapper xdomain-dispatch) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:OpenHostFile (object,byte[]&,byte[]&,string)
[ 2656]
[ 2656] Exception rethrown at [0]:
[ 2656] at (wrapper xdomain-invoke) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:OpenHostFile (string)
[ 2656] at CitizenFX.Core.InternalManager.LoadAssembly (System.String name) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\InternalManager.cs:118
[ 3047] Exception loading assembly System.Configuration.Install: System.IO.FileNotFoundException: Unable to find the specified file.
[ 3047]
[ 3047] Server stack trace:
[ 3047] at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (System.Int32 errorCode) [0x0000a] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 3047] at (wrapper cominterop) CitizenFX.Core.IScriptHost:OpenHostFile (string)
[ 3047] at (wrapper cominterop-invoke) CitizenFX.Core.IScriptHost:OpenHostFile (string)
[ 3047] at CitizenFX.Core.MonoScriptRuntime+WrapScriptHost.OpenHostFile (System.String fileName) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\MonoScriptRuntime.cs:254
[ 3047] at (wrapper remoting-invoke-with-check) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:OpenHostFile (string)
[ 3047] at (wrapper xdomain-dispatch) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:OpenHostFile (object,byte[]&,byte[]&,string)
[ 3047]
[ 3047] Exception rethrown at [0]:
[ 3047] at (wrapper xdomain-invoke) CitizenFX.Core.MonoScriptRuntime+WrapScriptHost:OpenHostFile (string)
[ 3047] at CitizenFX.Core.InternalManager.LoadAssembly (System.String name) [0x00000] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\InternalManager.cs:118
[ 3266] Exception loading assembly MySql.Data: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
[ 3266] at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
[ 3266] at System.Reflection.Assembly.GetTypes () [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 3266] at CitizenFX.Core.InternalManager.CreateAssemblyInternal (System.Byte[] assemblyData, System.Byte[] symbolData) [0x0002e] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\InternalManager.cs:78
[ 3266] at CitizenFX.Core.InternalManager.LoadAssembly (System.String name) [0x000a8] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\InternalManager.cs:141
[ 4578] Failed to instantiate instance of script KingfisherCoreServer.KingfisherCoreServer: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
[ 4578] at System.Diagnostics.TraceInternal.get_AppName () [0x0000e] in <7d13762c3f3046279fc4d30c52f6f595>:0
[ 4578] at System.Diagnostics.TraceInternal.TraceEvent (System.Diagnostics.TraceEventType eventType, System.Int32 id, System.String format, System.Object[] args) [0x0003d] in <7d13762c3f3046279fc4d30c52f6f595>:0
[ 4578] at System.Diagnostics.Trace.TraceError (System.String message) [0x00000] in <7d13762c3f3046279fc4d30c52f6f595>:0
[ 4578] at MySql.Data.MySqlClient.MySqlTrace.LogError (System.Int32 id, System.String msg) [0x00026] in <663f3bb44130474a9d4d9e70b96a11df>:0
[ 4578] at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver () [0x0002e] in <663f3bb44130474a9d4d9e70b96a11df>:0
[ 4578] at MySql.Data.MySqlClient.MySqlPool.GetConnection () [0x0001c] in <663f3bb44130474a9d4d9e70b96a11df>:0
[ 4578] at MySql.Data.MySqlClient.MySqlConnection.Open () [0x0016d] in <663f3bb44130474a9d4d9e70b96a11df>:0
[ 4578] at KingfisherCoreServer.DataService.canConnect () [0x00012] in <643fd66c72104398a2dff54f0b3c26f0>:0
[ 4578] at KingfisherCoreServer.KingfisherCoreServer.TestConnections () [0x00007] in <643fd66c72104398a2dff54f0b3c26f0>:0
[ 4578] at KingfisherCoreServer.KingfisherCoreServer..ctor () [0x00008] in <643fd66c72104398a2dff54f0b3c26f0>:0
[ 4578] at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
[ 4578] at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 4578] --- End of inner exception stack trace ---
[ 4578] at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00014] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 4578] at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x000a8] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 4578] at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00009] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 4578] at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00027] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 4578] at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00020] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 4578] at System.Activator.CreateInstance (System.Type type) [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0
[ 4578] at CitizenFX.Core.InternalManager.CreateAssemblyInternal (System.Byte[] assemblyData, System.Byte[] symbolData) [0x00069] in C:\gl\builds\4ff63adb\0\cfx\fivem\code\client\clrcore\InternalManager.cs:84
[ 4610] Instantiated instance of script KingfisherCoreServer.Events.
[ 4641] Started resource KingfisherCore
// Goes on to load the rest of the resources and start normally.
My __resource.lua
only calls the server_script
and client_script
for KingfisherCore
, as when adding the dependencies to this directory, it seemed to detect them automatically (considering the errors thrown due to missing MySQL.Data.dll
disappeared etc.
My thoughts:
- I’m loading the dependencies wrongly, or should be including them in the build one way or another.
- Copy and pasting all the contents (minus the .pdb’s and CitizenFX) from the build directory seems to make little difference.
- The
dependency
attribute for the resource manifest seems to be more about loading resources, rather than actual libraries.
My question:
- How should one be loading dependencies, like this particular one, when loading resources?
Server Debug.WriteLine() Output
When running Debug.WriteLine("foo");
on a server-sided resource, nothing is outputted to the CitizenFX.log
. This works fine with the client-sided resources.
Is there some particular method to this that I’m missing?
Thank you all for your help!