I was asked to design a central solution for an app that had to refer a library which was unmanaged and cannot be referred directly to our project. How do we do it.
Say, DLLClient.dll is your unmanaged dll.
Method 1
1) Create a managed dll that calls each and every function (required) of unmanaged, say Client_Wrapper_DLL.dll.
2) Now copy the DLLClient.dll to the bin folder (if there is no bin folder by default, create one by right clicking on the project, create new folder --> select "bin" from the drop down)
Say, DLLClient.dll is your unmanaged dll.
Method 1
1) Create a managed dll that calls each and every function (required) of unmanaged, say Client_Wrapper_DLL.dll.
2) Now copy the DLLClient.dll to the bin folder (if there is no bin folder by default, create one by right clicking on the project, create new folder --> select "bin" from the drop down)
3) Refer this dll to your ASP.Net project. Now the Wrapper dll will appear inside your bin folder. (or you can do this step first so that the bin folder will automatically created)
4) Call the functions of Client_Wrapper_DLL, which will automatically refer the unmanaged DLLClient.dll located in bin folder, whereas the Client_Wrapper_DLL acts as a proxy.
Method 2
1) Copy the DLLClient.dll to Windows/System32.
2) Create delegates to call functions inside DLLClient. Here the proxy code lie in your ASP.Net code.
That is the only difference.
The major difference will be where the unmanaged dll location is and how the proxy code is is created, either a separate dll or within your code behind.
I always recommend NOT to use the System32 folder, as that is and should be dedicated for OS related files. Let us not give any confusion to OS, if in case there happens to be an overlap you get screwed.
No comments:
Post a Comment