Calendar

<<  mars 2010  >>
lumamejevesadi
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

(août 27, 2007 08:40)

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 ?

Billets liés

Commentaires

avril 5. 2008 00:35

This was EXCELLENT. Thank you. Yes, I hate the warnings, too. More importantly, I love the step-by-step walk though that you provided. I have been in development for over 20 years, but you just cannot know everything and this helped.

William Olson

mai 28. 2008 21:10

THANK YOU for this very helpful tip.

rellis

décembre 18. 2009 21:29

Great tech info, that really helped me. Thanks for sharing!

0x0000008e

mars 3. 2010 11:21

Great explanation on using tlbimp! Help me remove a bad error.

0x0a

Ajouter un commentaire


 

  Country flag





Live preview

mars 12. 2010 15:36

Powered by BlogEngine.NET 1.2.0.0 | Theme by Pierre-Emmanuel Dautreppe