Skip to content

Missing .dll on Linux build of FXServer #2270

Open
@BuddiesTV

Description

@BuddiesTV

System.ComponentModel.Composition.dll is missing on Linux builds of the FXServer(should be here: citizen\clr2\lib\mono\4.5\Facades), which is why this following error occurs, would be good to have them added, so this issue is resolved.

Bug:
I'm encountering an issue when using the Autofac's ContainerBuilder.build() function on a server-side application. The function works as expected on Windows, but throws an exception when run on Linux.

The exception thrown is System.TypeLoadException: Could not resolve type with token 0100009f from typeref (expected class 'System.Lazy`2' in assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51')

Here are the classes where the issue is reproducible:

ServerClass.cs:

using CitizenFX.Core;
using Server.Utils.Helper;
using Server.Utils.Misc;

namespace Server
{
    public class ServerClass : BaseScript
    {
        public static ServerClass instance;
        public ContainerHelper containerHelper;

        public Logger logger;

        public ServerClass()
        {
            ServerClass.instance = this;
            logger = new();

            containerHelper = new();
        }
    }
}

ContainerHelper.cs:

using Autofac;
using System.Reflection;
using System;
using System.Collections.Generic;
using Server.Utils.Models;
using Server.Utils.Enums;

namespace Server.Utils.Helper
{
    public class ContainerHelper
    {
        public IContainer container;
        public ILifetimeScope lifetimeScope;

        public ContainerHelper()
        {
            try
            {
                ContainerBuilder containerBuilder = new();

                List<Type> allModules = LoadAllTypes(typeof(Utils.Models.Module<>));

                allModules.ForEach((module) => {
                    containerBuilder.RegisterType(module)
                        .AsImplementedInterfaces()
                        .AsSelf()
                        .SingleInstance()
                        .OnActivated((m) =>
                        {
                            ModuleBase moduleBase = m.Instance as ModuleBase;
                            ServerClass.instance.logger.Log(LoggerType.Info, $"Loaded module {Misc.ConsoleColor.Green}{moduleBase.Name}");
                        });
                });

                container = containerBuilder.Build(); //<- Exception is thrown here

                lifetimeScope = container.BeginLifetimeScope();
                allModules.ForEach((module) => {
                    lifetimeScope.Resolve(module);
                });
            } catch(Exception ex) {
                Console.WriteLine(ex.ToString());
            }
        }

        public List<Type> LoadAllTypes(Type genericType)
        {
            List<Type> allTypes = new();

            foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
            {
                if (type.BaseType != null && type.BaseType.IsGenericType && type.BaseType.GetGenericTypeDefinition() == genericType)
                {
                    allTypes.Add(type);
                }
            }

            return allTypes;
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    ScRT: C#Issues/PRs related to either C# scripting runtimesbugenhancementFeature or other request that adds functionality or improved usability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions