简体   繁体   中英

How to embed System.Data.SQLite.dll to my Class Library?

i'm building a class library for SQLite , when i build the project the System.Data.SQLite.dll comes as a standalone dll file and i need it to be merged with my class library in a single dll file i added System.Data.SQLite.dll as a ressource then , add / existing item , and then adding it as an embedded resource

then i drop this static constractor in the start of my namespace

static SimpleClass()
{
    AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
    {
        if (new AssemblyName(args.Name).Name.ToLowerInvariant() == "System.Data.SQLite")
        {
            String resourceName = "SQLlite." + new AssemblyName(args.Name).Name + ".dll";
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
            {
                Byte[] assemblyData = new Byte[stream.Length];
                stream.Read(assemblyData, 0, assemblyData.Length);
                return Assembly.Load(assemblyData);
            }
        }
        else
        {
            return null;
        }
    };
}

This is giving me errors like error CS1518: Expected class, delegate, enum, interface, or struct appreciate any help from you guys

如果要从两个组装一个,可以尝试ILMerge

This will ultimately fail. System.Data.SQLite is a PInvoke wrapper for SQLite.Interop.dll, which is an unmanaged dll, which is not resolved in .net.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM