简体   繁体   English

(C#)DLL内的参考DLL

[英](C#) Reference dlls inside dll

I wrote databases.dll and referenced 2 dlls inside. 我写了databases.dll并在其中引用了2个dll。

Npgsql.dll and MySql.Data.dll

I compiled my project to databases.dll in command line like this: 我在命令行中将我的项目编译为Databases.dll,如下所示:

csc.exe /target:library /r:Npgsql.dll,MySql.Data.dll /out:databases.dll PostgreSql.cs MySql.cs

databases.dll is compiled without problems. 编译databases.dll没有问题。

Problem appears when I want to test it creating new project and reference database.dll . 当我要测试它以创建新项目并引用database.dll时出现问题。 Program is compiling but when it try to use dll code it brings the error: TypeInitializationException was unhandled . 程序正在编译,但尝试使用dll代码时会出现错误: TypeInitializationException was unhandled

I was trying to copy both dlls to the directory where the compilation target is. 我试图将两个dll复制到编译目标所在的目录中。

I want to ask if there is possible to: 我想问一下是否可以:

  1. Create dll that reference to other dlls. 创建引用其他dll的dll。

  2. Provide dll to the enduser without referenced dlls and ask them to do so if they want to use each part of the dll. 向没有参考dll的最终用户提供dll,如果他们要使用dll的每个部分,请他们这样做。 So when coder want to use MySql he have to provide MySql.dll to the compilation. 因此,当编码器要使用MySql时,他必须提供MySql.dll进行编译。

I hope I made myself clear cause my English ain't perfect ;) 我希望我能说清楚一点,因为我的英语不太好;)

由于Npgsql.dllMySql.Data.dll都是依赖项DLL,因此您的项目都需要引用它们才能对其进行编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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