简体   繁体   中英

VS2005 C#: Reloading a reference

Similar to coryr (see this question ), I am referencing a dll within a C# project. The DLL often changes but I the C# project does not recognize this. Unlike coryr, the DLL is a VB6 ActiveX DLL. Any suggestions for how to reload the reference other than removing and adding it?

The problem here is that when you add a reference to a COM DLL, you don't actually add a reference to the DLL. Instead a primary interop assembly is generated for the DLL and a reference is added to that. When the main DLL is changed a new PIA (primary interop assembly) is not generated.

You can verify this by doing the following

  1. Expand the references collection
  2. Hit F4. This will bring up the properties page
  3. Look at the path property

The path will be the path to the PIA.

The problem is that VS is watching the PIA and not the original DLL. So when the original DLL changes it doesn't actually reload the reference. The best way to get this to work is to unfortunately delete and re-add the reference.

Another solution is to manually generate the PIA and place it over the referenced PIA on disk. This will force VS to reload the DLL reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM