none
C# dll update : when is regasm needed ? RRS feed

  • Question

  • Hi,

    I'm working with Windows XP, the 2.0 .Net framework and VS2005, with the KB908002 patch applied.

    I have an Excel spreadsheet referencing a C# dll. The .xls, .dll and .tlb files are shared, on a server.

    Everything works fine when I generate the dll and tlb files and then run regasm with the /codebase option on every client machine.
    My problem has to do with an update to the dll.
    (in the AssemblyInfo.cs file, both AssemblyVersion and AsemblyFileVersion are constant, set to "1.0.0.0")

    If I modify an already existing method of an already existing class, or add a new method to an already existing class, I don't have to run regasm again on the client machines ; they "see" the change and are able to run the new method.
    However, if I add a new class to the dll, the client machines are unable to run any piece of code using the new class. They are of course able to do it if I re-apply regasm.

    I have two questions :
    1. Why this behaviour, i.e. why is a new function correctly handled, while a new class is not ?

    2. Is it possible to set things up so that I only have to run regasm once (or more generally I only have to perform a set of commands once) on a client machine, and any further update to the dll and tlb will automatically be properly received by the client machine, without any re-registration needed ?

    Please ask if you need more info.
    Thanks for your time,
    Gilles
    Friday, July 18, 2008 12:52 PM

Answers

  • A new C# class generates a new COM co-class with a new CLSID and new interface(s) with new IIDs.  Those have to be registered in order for a client to be able to find the assembly that implements them.  And that takes running Regasm.exe.   Registry-free COM with a manifest is almost certainly not an option with Excel.

    Adding a function just expands the v-table of the COM interface.  Modifying a COM interface without also changing its IID is strictly verboten btw.  You're probably getting away with it only because you're updating all of the clients in sync with your server.

    Hans Passant.
    Friday, July 18, 2008 6:33 PM
    Moderator

All replies

  • A new C# class generates a new COM co-class with a new CLSID and new interface(s) with new IIDs.  Those have to be registered in order for a client to be able to find the assembly that implements them.  And that takes running Regasm.exe.   Registry-free COM with a manifest is almost certainly not an option with Excel.

    Adding a function just expands the v-table of the COM interface.  Modifying a COM interface without also changing its IID is strictly verboten btw.  You're probably getting away with it only because you're updating all of the clients in sync with your server.

    Hans Passant.
    Friday, July 18, 2008 6:33 PM
    Moderator
  • Thanks for your reply,
    Gilles
    Saturday, July 19, 2008 3:44 PM
  • Hello Hans,
    I am trying to use Reg-Free Com with a manifest in Excel VBA and have not been successful. I noted in your reply you said Registry-Free COM with a manifest is not an option. Why?

    Thanks
    sdj
    Wednesday, March 18, 2009 11:20 AM
  • Because you can't control either Excel.exe nor the directory it lives in.  The DLL Hell problem is a lot worse, some rogue add-on that wants its own manifest in place will overwrite yours.
    Hans Passant.
    Wednesday, March 18, 2009 10:11 PM
    Moderator