问题描述
我写了 databases.dll
并在其中引用了两个dll。
I wrote databases.dll
and referenced 2 dlls inside.
Npgsql.dll and MySql.Data.dll
我将我的项目编译到database.dll在命令行像这样:
I compiled my project to databases.dll in command line like this:
csc.exe /target:library /r:Npgsql.dll,MySql.Data.dll /out:databases.dll PostgreSql.cs MySql.cs
databases.dll
被编译没有问题。
当我想测试它创建新项目和引用时出现问题 database.dll
。
程序正在编译,但是当它尝试使用dll代码时会出现错误: TypeInitializationException未被处理
。
Problem appears when I want to test it creating new project and reference database.dll
.Program is compiling but when it try to use dll code it brings the error: TypeInitializationException was unhandled
.
我正在尝试将两个DLL复制到编译目标的目录。
I was trying to copy both dlls to the directory where the compilation target is.
我想询问是否有可能:
-
创建引用其他dll的dll。
Create dll that reference to other dlls.
为最终用户提供dll引用dll并要求他们这样做,如果他们想使用dll的每个部分。所以当编码器想要使用MySql时,他必须提供 MySql.dll
到编译。
Provide dll to the enduser without referenced dlls and ask them to do so if they want to use each part of the dll. So when coder want to use MySql he have to provide MySql.dll
to the compilation.
我希望自己清楚原因我的英文不完美;)
I hope I made myself clear cause my English ain't perfect ;)
推荐答案
As Npgsql.dll
和 MySql.Data.dll
都是依赖DLL,它们都需要按照项目引用为了编译。
As Npgsql.dll
and MySql.Data.dll
are both dependency DLLs, they both need to be referenced by your project in order for it to compile.
这篇关于(C#)dll里面引用dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!