We want to develop addins for outlook, word and excel. As of now I am aware of 2 types of solutions. One to go for Shared Add-in (COM based) and other to build VSTO based Add-in. As I am new to this, which would be the better option? (Or if there is 3rd way,please let me know) We are targeting Office 2003 and 2007 both. And I would prefer developing this addins in C#.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
If you are going to be developing in C#, I highly recommend sticking with VSTO. This has a much simpler add-development framework, and works perfectly with C#.
Going the COM route, especially with C#, is just adding extra pain that's unnecessary at this point.
Not directly an answer to your question but also worth considering before starting add-in development: As already said by Reed, when developing an Office add-in using VB.Net will make life a lot easier than using C#.
A call into the Office object model typically leaves out several optional parameters. However, in C# - because C# does not (yet) have optional parameters - you will have to specify each and every of the optional parameters. Not enough, for COM add-ins you will also have to take care of boxing the arguments yourself, i.e. instead of passing a simple bool or int you have to convert it to a reference type first. All this makes code quite unreadable.
E.g. the code to open a document in Word would look like that in C#:
whereas the same in VB.Net would be much easier to read and write:
(Additional info: With C# 4.0 this will become much simpler using dynamic)