![](/img/trans.png)
[英]Is it possible to create a DLL of WCF Service which having webHttpBinding
[英]Is it possible to create a DLL which contains another DLL?
我正在做一個項目。 任務是創建一個 DLL 項目。 在那個項目中,我有一個帶有一組方法的現有 DLL。 通過使用現有的 DLL,我可以調用一些方法並在新的 DLL 中創建一些方法。
這在 C# 中可能嗎? 創建這樣一個項目的可能性和方法是什么?
如果你想在你自己的 DLL 的內容中隱藏那個 DLL,你可以簡單地把它放到資源中。 從資源的角度來看,DLL 只是一個文件,就像任何其他文件一樣,您可以簡單地將它添加到程序資源中,然后將文件放到您需要的地方。
但是,這將禁止您使用隱式鏈接,您必須顯式鏈接 DLL 。 MSDN 已經和這里提供了一個相當合理的教程。
using System;
using System.Reflection;
public class Asmload0
{
public static void Main()
{
// Use the file name to load the assembly into the current
// application domain.
Assembly a = Assembly.Load("example");
// Get the type to use.
Type myType = a.GetType("Example");
// Get the method to call.
MethodInfo myMethod = myType.GetMethod("MethodA");
// Create an instance.
object obj = Activator.CreateInstance(myType);
// Execute the method.
myMethod.Invoke(obj, null);
}
}
如果你想創建你自己的 DLL 只使用舊的,你可以只添加引用。 然后你可以設置"Use Copy Local" ,但你必須分發兩個文件:
如果您只想通過編譯器/鏈接器(內置到visual studio)制作“靜態鏈接”,您需要使用靜態鏈接庫(LIB)而不是動態鏈接庫(DLL)...
或者您可以嘗試閱讀“如何靜態鏈接 .DLL? ”,這似乎提供了一些有關如何執行此操作的指導(專有軟件)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.