[英]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 我正在为SQLite构建类库,当我构建项目时,System.Data.SQLite.dll作为一个独立的dll文件出现,我需要将其与类库合并到一个单独的dll文件中,并添加了System.Data。然后将.SQLite.dll作为资源添加/现有项,然后将其添加为嵌入式资源
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 这给了我类似错误CS1518的错误:期望的类,委托,枚举,接口或结构体感谢您的任何帮助
如果要从两个组装一个,可以尝试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.
System.Data.SQLite是SQLite.Interop.dll的PInvoke包装,后者是一个非托管dll,无法在.net中解析。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.