Question

Assume that we have a .NET project in VS 2005 (VB .Net). This project uses non-GUI COM object. When I add the reference to this object, VS creates interop dll. But I add new methods to COM object in another project. How can I update interop dll without explicit calling of tlbimp? I want Intellisense to show the list of new methods in this COM object.

Was it helpful?

Solution

If I understood you correctly you are having a COM server (apparently in-process / DLL), that hosts objects, that you are updating. And you want those updates to be available through IntelliSense in the client project, when you have not yet compiled the COM server, right?

If so: this is not possible. Let me describe why:

IntelliSense only builds a documentation cache for the project's references. Referencing COM servers isn't the same as referencing .NET projects. For .NET project's it is able to build up the documentation cache directly from the code model. However COM servers are usually described in a language, the compiler does not know! tlbimp generates a .NET wrapper that calls the COM server for you. IntelliSense is able to understand the wrapper (The interop DLL, which is nothing more than an automatically generated .NET DLL), but not what it actually does. So you allways need to keep the wrapper up to date.

Whenever you make a change to the COM server, you need to register it (using regsvr32), so that the changes are "visible" to the client (in this case to tlbimp). Then you have to re-add the reference to your .NET project, which results in tlbimp generating a new interop DLL, that IntelliSense understands. That's the deal with COM under .NET environments...

However you could try to automate your build process a little bit further:

  1. On your server project, call tlbimp in a post-build event, and let it create a Primary Interop Assembly.
  2. Automatically deploy the PIA to the GAC.
  3. In your client project (.NET project), reference the PIA.
  4. Every time you've build a new server project, refresh the IntelliSense cache in your client project ("Edit" -> "IntelliSense" -> "Refresh Local Cache", or Ctrl + Shift + R).

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top