none
How to unregister a COM wrapped .NET assembly?

    Question

  • Hi All,

    I created a COM exposed .NET 2.0 dll and registered with my Windows 2000 operating system using 'regasm' and 'gacutil' Then I tried to call this component from my classic ASP page. It worked fine. But, I need to change the functionality of my assembly. I unregistered it again using  'regasm' and 'gacutil'  utilities and copied my new .NET DLL and registered again.  But for some reason, i still have a pointer to my old assembly and new calls to the DLL from ASP page are not working.

    Any Ideas?  I appreciate any help.

    Thanks

     

     

    Wednesday, December 13, 2006 4:07 PM

Answers

  • It is actually a very simple process

    To Register

    SET WorkFolder= '<directory>'

    regasm.exe %WorkFolder%\xxx.dll /Codebase

    regtlib.exe %WorkFolder%\xxx.tlb

     

    To Unregister

    SET WorkFolder= '<directory>'

    regasm.exe /unregister %WorkFolder%\xxx.dll

    unregister tlb also with normal unregister utilities/command.

    Tuesday, January 16, 2007 6:10 AM

All replies

  • Describe in detail why you conclude that the calls "are not working".
    Wednesday, December 13, 2006 8:08 PM
  • just use the regasm, but append the /unregister i.e. "regams yourassemblyname.dll /unregister"
    Thursday, January 04, 2007 5:13 PM
  • This is when it really helps to know the CLSID of your COM class because the registry at HKLM\CLSID\{Class guid} contains the info that will connect a COM client to your class. If you have changed the version (because the default AssemblyVersion string is 1.0.*) there will be version-specific connections in InprocServer32\<version> - that might be the problem. Your older and newer versions might both be registered but the default may still be to connect you to the prior version.

    If you run regasm <your assembly> /regfile:some.reg you'll see the CLSID entries so you can go check what's going on (and the /regfile option doesn't do any registration).

    Friday, January 05, 2007 7:33 PM
  • Try using regsvcs to register the file: regsvcs nameofdll.dll

    to unregister use regsvcs /u nameofdll.dll

    You can also use lazy registration via Setup and Deployment project and add a class that implements System.Configuration.Install.Installer

    Here's a sample of what i did.

     

    RunInstaller(true)]
    public class Installer : System.Configuration.Install.Installer
    {
    private System.ComponentModel.Container components = null;
    public Installer()
    {
    InitializeComponent();
    }
    private void InitializeComponent()
    {
    components =
    new System.ComponentModel.Container();
    }
    }

    Thursday, January 11, 2007 5:51 PM
  • Thanks everybody.  I am doing my registration and unregistartion like this:

    Unregister:
    gacutil /u AHToIg
    regasm /u d:\AHToIgenti\AHToIg.dll /tlb:d:\AHToIgenti\AHToIg.tlb

    Register:
    regasm d:\AHToIgenti\AHToIg.dll /tlb:d:\AHToIgenti\AHToIg.tlb
    gacutil /i d:\AHToIgenti\AHToIg.dll

    Most of the time it works.  But sometimes, I get an error while registering that AHToIg.tlb is not accessible.  When I physically try to delete tha file, I get an error 'it is being used by another program'. But I can delete it if I reboot my server. I am not sure what is causing this. I can not afford to reboot everytime I need to register as this is production server.

    My next question is, is it necessary to export to a TLB file in order for me to use my DLL from classic ASP pages? Can simply do this instead?

    regasm d:\AHToIgenti\AHToIg.dll
    gacutil /i d:\AHToIgenti\AHToIg.dll

    Regards,

    Thursday, January 11, 2007 9:43 PM
  • Interesting.  The documentation indeed tells you that you should first regasm, then gacutil.  That doesn't look right to me.  regasm will register the wrapper at its build location.  But gacutil will copy the wrapper into the GAC, a different folder.  The COM client will try to load the DLL from its registered location.  Which, in the prescribed order, will be the build location, not the GAC folder.  I would expect it to go kaboom when you delete the wrapper in the build location, thinking that would be safe because you GAC-ed it...
    Thursday, January 11, 2007 10:39 PM
  • nobugz: I suspect WinFXGuy didn't use a codebase in the Regasm, so doing regasm and then gacutil works.

    Anyway, if AssemblyVersions and Classids aren't explicitly specified they will change on a rebuild, so I suspect he rebuilt the new assembly and called regasm to unregister that new one, which of course will do nothing if Assemblyversion and Classids have changed because the new version has never been registered. Also, he may still be using a old Progid in the ASP page.

    Sunday, January 14, 2007 4:46 PM
  • Thanks Phil, /codebase; now it makes sense.
    Sunday, January 14, 2007 5:11 PM
  • That's correct Phil and nobugz. I did not use codebase while registering the assembly. 

    I still need to know, if it I am required to export the assembly to a TLB file, in order for me to use in ASP pages.

    Monday, January 15, 2007 4:31 PM
  • From ASP pages you shouldn't need a type library. If I recall my COM correctly, you're using script from ASP, and scripting uses the standard automation  marshaler.

    Monday, January 15, 2007 7:08 PM
  • It is actually a very simple process

    To Register

    SET WorkFolder= '<directory>'

    regasm.exe %WorkFolder%\xxx.dll /Codebase

    regtlib.exe %WorkFolder%\xxx.tlb

     

    To Unregister

    SET WorkFolder= '<directory>'

    regasm.exe /unregister %WorkFolder%\xxx.dll

    unregister tlb also with normal unregister utilities/command.

    Tuesday, January 16, 2007 6:10 AM
  • I am facing the same kind of problem. The requirement is --

    1) I need to build a COM library using .NET 2.0

    2) Use this library from ASP and ASP.NET both.

    I have created the COM library and registered using the REGASM for ASP. Everything is working fine. Now I need to unregister the library. For that I am using REGASM /unregister. Here problem starts. The registry is getting affected since I could not see any registry keys in it. But the application is running properly which should not be the case. It should fail because i have unregistered the library. That means somewhere the registry in not giving the immediate effect of unregister.

    The application fails when I restart the system after unregister. So I need your inputs on this. Why the unregister effect appears only after system restart. I need to avoid the system restart.

    You might be wondering why i am asking this question. I can not restart production system in case any changes occurs. So I need to find solution for this. Please give me your inputs.

     

    Thursday, March 01, 2007 9:25 PM
  • A common issue is that people don't explicitly assemblyversion. Then what happens is that every build produces a different assemblyversion, and that's extremely important because it's part of the registration. You build another assembly and do regasm /u on it and it will not work because you're trying to unregister a different version that was never registered. Similar things happen if you don't specify classid or interface id, because they'll get changed automatically by the compiler.
    Saturday, March 03, 2007 8:07 PM
  • how do you unregister dlls with old dll versions?

    before registering new one?

    Thursday, July 15, 2010 11:38 AM