Hello,
a few time ago we were needing to update a website IIS' parameters to add some mime types.
In order to do that, we must use two COM components that you can find in %windir%\system32:
- Active DS IIS Namespace Provider (adsiis.dll)
- Active DS Type Library (activeds.tlb)
We won't deal here how to add some mime types to IIS by code but how to create wrappers around these COM DLLs to be able to use them in .NET.
Of course, you all know that we can just "Add a new reference" to our project to let Visual Studio create these wrappers for us.
Article finished.
Not completely. Indeed if you do that and that you compile, you will see bunch of warnings (40 in fact) like for example :
The type library importer could not convert the signature for the member 'ADS_OCTET_STRING.lpValue'.
The type library importer could not convert the signature for the member '__MIDL___MIDL_itf_ads_0000_0002.lpValue'.
The type library importer could not convert the signature for the member 'ADS_NT_SECURITY_DESCRIPTOR.lpValue'.
..........
If you are like me, no warning is acceptable in a project and so we have to do it differently. Of course in this case, there is no way for us to correct these warnings, but maybe we can hide them by creating the COM wrapper ourselves
To achieve this, we will use "tlbimp.exe" which is located in "%programfiles%/Microsoft Visual Studio 8/SDK/v2.0/bin" or in the corresponding folder depending of which version of Visual Studio you use.
To simplify our command lines, we'll update the %path% environment variable to include the tlbimp path, and we'll run a command prompt into "%windir%\system32".
Step 1 : Generate the ActiveDs.dll
As this DLL is referenced by adsiis.dll, we'll start by this one. Note that we want to specify that we are not interested by any warning
tlbimp activeds.tlb /out:c:\temp\Interop.ActiveDs.dll /silent
Note that this command line use the type library file (activeds.tlb) to generate the DLL. We'll generate it in the temp directory and we'll keep the name that is normally generated by Visual Studio
Step 2 : Generate the AdsIis.dll
In this case, we'll specify that it references "Interop.ActiveDs.dll" and we'll also specify the main namespace of the DLL. We have chosen the namespace that is generated by Visual Studio.
tlbimp adsiis.dll /out:c:\temp\Interop.IISOle.dll
/reference:c:\temp\Interop.ActiveDs.dll /namespace:IISOle
Step 3 : Use the DLLs
Now you have two valid DLLs that can be used by any .NET project. And due to the "/silent" flag used in Step 1, no more warning is shown in Visual Studio.
Question:
Experts, do you know another way to achieve to the same result ? But maybe without using a command line ?