HowTo: Set a reference to CDOSYS
You could set a reference directly to the CDOSYS file. However, there this is a more elegant way overall and that is to do it in Visual Studio:
Click on Solution Explorer.
Right click the "References" node in the tree and select "Add Reference…".
Click on the COM tab.
Navigate to the "Microsoft CDO for Windows 2000 Library" and select it. Click OK.
When the reference is set to cdosys.dll, you will see 2 interop assemblies generated called CDO and ADODB. Don't confuse the ADODB interop with ADODB used with databases or ADODB.NET. Both assemblies are needed and must be created by the action of setting a reference to cdosys.dll. If you remove and reset a reference to CDOSYS then be sure to delete the ADODB and CDO interops from the file system folder after removing the reference so that the new ones which will be generated after setting a new reference will be created correctly.
Under 32bit Windows CDOSYS exists in the C:\Windows\System32\ folder. This is because CDOSYS is a system component and C:\Windows\System32 is the folder where system components at the bitness level of the OS are stored.
C:\Windows\System32\ cdosys.dll.
Under 64bit Window there are two different cdosys.dll files – one for 32bit code to use and one for 64 bit code to use. 32bit system files are put into the C:\Windows\SysWOW64 folder on 64bit versions of Windows and the C:\Windows\System32\ folder has system files at the bitness level of the OS.
For 32 bit applications on a 64bit version of Windows:
C:\Windows\SysWOW64\cdosys.dll.
For 64 bit applications on a 64bit version of Windows:
C:\Windows\System32\cdosys.dll.
Here are some points:
- Be sure to NOT include the cdosys.dll file in your released applications since it is a Windows component which is to only be installed by installing Windows or an update to Windows or other Microsoft products.
- Never register cdosys.dll since it can cause issues with applications on your system since it's a primary system component.