0

I wrote an add-in for Enterprise Architect. It's a COM Object. This add-in uses some other project dll's.

I created an installer which registers the Add-In's dll. This class is in the add-in's project, let's call it MyProject.dll.

/// <summary>
/// Installer class for Enterprise Architect Add-In
/// </summary>
[RunInstaller(true)]
public class ComInstaller : Installer
{
    #region Public Methods

    public override void Install( System.Collections.IDictionary stateSaver )
    {
        base.Install( stateSaver );
        RegistrationServices regsrv = new RegistrationServices();
        if ( !regsrv.RegisterAssembly( GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase ) )
        {
            throw new InstallException( "Failed to register type library for COM" );
        }            
    }

    public override void Uninstall( System.Collections.IDictionary savedState )
    {
        base.Uninstall( savedState );
        RegistrationServices regsrv = new RegistrationServices();
        if ( !regsrv.UnregisterAssembly( GetType().Assembly ) )
        {
            throw new InstallException("Failed to unregister type library for COM");
        }
    }

    #endregion
}

If the add-in runs, I can't build my solution because access is denied. The add-in uses the MyProject.dll which is in the Debug folder instead of the installed one.

How can I solve this?

Thanks, Maestro

maestro
  • 671
  • 1
  • 13
  • 27

2 Answers2

1

This is how registration works. You can disable automatic registration at build:

TODO screenshot

Note that there is a way out of COM DLL hell with (Vista+?) manifest files:

Community
  • 1
  • 1
sehe
  • 374,641
  • 47
  • 450
  • 633
  • Thought I'd mention alternative COM 'registration' in manifests (similar to `.local` dll deployment) – sehe Nov 21 '11 at 13:38
0

Welcome back to the Dll hell days :) Unfortunately COM dlls are instatiated on the handler of the caller, so once your dlls is in use by the caller app, even that you have unregistered it (in your case with the uninstaller), the dll could still be in use, and you need to kill all the caller processes to be able to overwrite the dll. Most of the times if you completely kill the caller app (in your case the instances of EA) and wait a few seconds you should be able to re-compile, but sometimes the process stay in memory so you would need to run something like ListDLLs from sysinternals to check who is using your dll and kill the whole process tree.

Claiton Lovato
  • 2,382
  • 1
  • 22
  • 23
  • Thank you guys, I forgot to switch off COM registration when it builds. – maestro Nov 21 '11 at 13:32
  • But now, the installer has some errors, I can't use my add-in, I think it's not registered. Do you have a link to some tutorial how can it be done? Or I just made some mistakes in the installer code? – maestro Nov 21 '11 at 13:35
  • Finally I managed to register that COM object. The solution is that you have to implement something similar that I, then you have to add the primary output to your installers custom actions Install folder. – maestro Nov 21 '11 at 17:37