mscorlib.dll problem only during uninstall in 64bit

Add-in Express™ Support Service
That's what is more important than anything else

mscorlib.dll problem only during uninstall in 64bit
 
developer_cp




Posts: 48
Joined: 2016-10-28
I've been testing my stuff on 64 bit machine/Outlook now, I'm having this really weird problem during install.
I log my stuff during the uninstall procedure, everything had been working fine in 32 bit.

I'm not sure what how to interpret this here, because the exact same logger class runs fine inside the 64 bit Outlook.


The mscorlib.dll that it gets pointed to, is the 32 bit version... I've already compiled my solution with "AnyCPU", and I've set the Platform to x64, and I've also made sure both the Outlook and OS are 64... Can someone give me some hint? Or what is wrong with it?

Again, this runs fine in 32 bit and 64 bit, this ONLY happens during 64 bit UNINSTALL.



Add-in Express Registrator Log File: 11/24/2016 19:11:19

Installation directory: C:WINDOWSInstaller
Registrator version: 8.4.4395.0
Operating System: Microsoft Windows 10 Professional (build 14393), 64-bit
Process Owner: Administrator
Command Line: "C:WINDOWSInstallerMSI7C7C.tmp" /uninstall="C:Program FilesTestProgramTest_Program.dll" /log=%RoamingAppDataFolder%/TestProgram
Run 'As Administrator': No
Process Elevated: No
Integrity Level: Medium
UAC (User Account Control): On
--------------------------------------------------------------
19:11:19 0456 Starting the add-in unregistration process.
19:11:19 0456 Loading mscoree.dll
19:11:19 0456 Success.
19:11:19 0456 .NET Framework installation directory: 
19:11:19 0456 The latest version of .NET Framework: 'v4.0.30319'
19:11:19 0456 Loading CLR: v4.0.30319.
19:11:19 0456 Calling CLRCreateInstance method.
19:11:19 0456 Success.
19:11:19 0456 Calling GetRuntime method.
19:11:19 0456 Success.
19:11:19 0456 Checking if the hosting API of .NET Framework v4.0 beta is installed.
19:11:19 0456 The hosting API is up to date.
19:11:19 0456 Calling GetInterface method for the CorRuntimeHost interface.
19:11:19 0456 Success.
19:11:19 0456 Starting CLR...
19:11:19 0456 Success.
19:11:19 0456 Getting the CLR version.
19:11:19 0456 The CLR v4.0.30319 has been initialized successfully.
19:11:19 0456 Creating a new domain setup.
19:11:19 0456 Success.
19:11:19 0456 The 'shadow copy' is disabled.
19:11:19 0456 Creating a new application domain.
19:11:19 0456 Success.
19:11:19 0456 Getting the base directory for the domain.
19:11:19 0456 Success. The directory is 'C:Program FilesTestProgram'.
19:11:19 0456 Searching for the Add-in Express core library.
19:11:19 0456 Success. The 'AddinExpress.MSO.2005.dll' file is found.
19:11:19 0456 Creating an instance of the 'AddinExpress.Deployment.ADXRegistrator' class.
19:11:19 0456 Assembly identity is 'AddinExpress.MSO.2005'.
19:11:19 0456 Success.
19:11:19 0456 Unwrapping the instance of the 'AddinExpress.Deployment.ADXRegistrator' class.
19:11:19 0456 Success.
19:11:19 0456 Calling the managed unregistration procedure (DISPID = 1610743823).
19:11:24 0456 Managed Error: 
(Inner Exception)
Date and Time:         11/24/2016 7:11:24 PM
Machine Name:          YUL1DQAWIN1001
IP Address:            fe80::2c92:544:46da:d398%5
Current User:          YUL1DQAWIN1001User

Application Domain:    C:Program FilesTestProgram
Assembly Codebase:     file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
Assembly Full Name:    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Assembly Version:      4.0.0.0

Exception Source:      mscorlib
Exception Type:        System.IO.IOException
Exception Message:     The process cannot access the file 'C:UsersUserAppDataRoamingTestProgramuninstall_20161125.log' because it is being used by another process.
Exception Target Site: WinIOError

---- Stack Trace ----
   System.IO.__Error.WinIOError(errorCode As Int32, maybeFullPath As String)
       mscorlib.dll: N 0471 (0x1D7) IL 
   System.IO.FileStream.Init(path As String, mode As FileMode, access As FileAccess, rights As Int32, useRights As Boolean, share As FileShare, bufferSize As Int32, options As FileOptions, secAttrs As SECURITY_ATTRIBUTES, msgPath As String, bFromProxy As Boolean, useLongPath As Boolean, checkHost As Boolean)
       mscorlib.dll: N 0928 (0x3A0) IL 
   System.IO.FileStream..ctor(path As String, mode As FileMode, access As FileAccess, share As FileShare)
       mscorlib.dll: N 0000 (0x0) IL 
   Test.Logger.getFileStream(sFileName As String)
       Logger.cs: line 0123, col 13, IL 0159 (0x9F)
   Test.Logger.InitLogger(filename As String, modes As LoggerMode[])
       Logger.cs: line 0130, col 13, IL 0014 (0xE)
   Test.AddinModule.ExtraUninstallRoutines()
       AddinModule.cs: line 0593, col 13, IL 0027 (0x1B)
   Test.AddinModule.UninstallControls()
       AddinModule.cs: line 0583, col 13, IL 0001 (0x1)
   AddinExpress.MSO.ADXAddinModule.ADXUnregister(t As Type)
       mscorlib.dll: N 0563 (0x233) IL 
   Test.AddinModule.AddinUnregister(t As Type)
       AddinModule.cs: line 0578, col 13, IL 0001 (0x1)



(Outer Exception)
Date and Time:         11/24/2016 7:11:24 PM
Machine Name:          YUL1DQAWIN1001
IP Address:            fe80::2c92:544:46da:d398%5
Current User:          YUL1DQAWIN1001User

Application Domain:    C:Program FilesTestProgram
Assembly Codebase:     file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
Assembly Full Name:    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Assembly Version:      4.0.0.0

Exception Source:      mscorlib
Exception Type:        System.Reflection.TargetInvocationException
Exception Message:     Exception has been thrown by the target of an invocation.
Exception Target Site: InvokeMethod

---- Stack Trace ----
   System.RuntimeMethodHandle.InvokeMethod(target As Object, arguments As Object[], sig As Signature, constructor As Boolean)
       mscorlib.dll: N 00000 (0x0) JIT 
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(obj As Object, parameters As Object[], arguments As Object[])
       mscorlib.dll: N 0022 (0x16) IL 
   System.Reflection.RuntimeMethodInfo.Invoke(obj As Object, invokeAttr As BindingFlags, binder As Binder, parameters As Object[], culture As CultureInfo)
       mscorlib.dll: N 0085 (0x55) IL 
   AddinExpress.Projects.Common.Utilities.CallUserDefinedRegistrationMethod(rootKey As ADXRegistryKey, type As Type, bRegister As Boolean, targetHive As ADXTargetRegistryHive)
       mscorlib.dll: N 0332 (0x14C) IL 
   AddinExpress.Projects.Common.Utilities.UnregisterType(t As Type, allUsers As Boolean, targetHive As ADXTargetRegistryHive, callUnregMethod As Boolean, removeProgID As Boolean)
       mscorlib.dll: N 0183 (0xB7) IL 
   AddinExpress.Projects.Common.Utilities.UnregisterAssembly(assembly As Assembly, allUsers As Boolean, targetHive As ADXTargetRegistryHive, callRegMethod As Boolean, removeProgID As Boolean)
       mscorlib.dll: N 0040 (0x28) IL 
   AddinExpress.Deployment.AddinDomainAdapter.RegisterForComInterop(register As Boolean, dllType As String, dllPath As String, showExceptions As Boolean)
       mscorlib.dll: N 0329 (0x149) IL 
   AddinExpress.Deployment.ADXRegistrator.RegisterAssembly(commandLine As String)
       mscorlib.dll: N 0815 (0x32F) IL 



19:11:24 0456 The add-in unregistration process is completed with HRESULT = -2147467259.
Posted 24 Nov, 2016 19:33:27 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Hello Eric,

The exception which causes the issue is:

Exception Message: The process cannot access the file 'C:\Users\User\AppData\Roaming\TestProgram\uninstall_20161125.log' because it is being used by another process.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 25 Nov, 2016 09:35:12 Top
developer_cp




Posts: 48
Joined: 2016-10-28
Ok, the problem wasn't really caused by the exception with my log file, but rather I was using the wrong AddinExpress.MSO.2005.DLL.

Originally the person who coded this copied the ADX dll into a local folder, but I've updated Addin Express to the latest version and redo all the references in the project. But the WiX was still copying the old dll from the old local folder for 64 bit. After I fixed them up, everything works fine.

I have a question however, is it a good practice to pull the DLL directly from C:\Program Files (x86)\Add-in Express\Add-in Express for .NET\Bin?
Posted 28 Nov, 2016 14:20:43 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Hello Eric,

The best practice is to deploy the assembly used by the add-in project. This helps avoiding the The located assembly's manifest definition does not match the assembly reference exception; see e.g. ADX Loader Error code: 0x80131040.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 29 Nov, 2016 02:49:37 Top
developer_cp




Posts: 48
Joined: 2016-10-28
How can I find out which adxloader.dll it uses during uninstall procedure?
I am still fixing this issue, where on installation and operation, everything ran fine, it loaded Redemption64.dll when Outlook is running.

However, when I uninstall the plugin, it would end up loading Redemption.dll (32 bit).

According to the author of Redemption, the RedemptionLoader would only load the correct DLL based on mode of which Outlook is loaded?
So if is a 32bit process then it would load the 32bit Redemption.dll, otherwise it would load the 64bit.

The only explanation i can have is that, during uninstall, it is loading the 32 bit adxloader.dll which in turn causes Redemption to load the 32bit dll...

This is the uninstall log thrown by ADXregistrar.

Add-in Express Registrator Log File: 12/05/2016 15:23:32

Installation directory: C:WINDOWSInstaller
Registrator version: 8.4.4395.0
Operating System: Microsoft Windows 10 Professional (build 14393), 64-bit
Process Owner: Administrator
Command Line: "C:WINDOWSInstallerMSIDCC8.tmp" /uninstall="C:Program FilesTestProgramMyTest.dll" /log=%RoamingAppDataFolder%/TestProgram
Run 'As Administrator': No
Process Elevated: No
Integrity Level: Medium
UAC (User Account Control): On
--------------------------------------------------------------
15:23:32 0456 Starting the add-in unregistration process.
15:23:32 0456 Loading mscoree.dll
15:23:32 0456 Success.
15:23:32 0456 .NET Framework installation directory: 
15:23:32 0456 The latest version of .NET Framework: 'v4.0.30319'
15:23:32 0456 Loading CLR: v4.0.30319.
15:23:32 0456 Calling CLRCreateInstance method.
15:23:32 0456 Success.
15:23:32 0456 Calling GetRuntime method.
15:23:32 0456 Success.
15:23:32 0456 Checking if the hosting API of .NET Framework v4.0 beta is installed.
15:23:32 0456 The hosting API is up to date.
15:23:32 0456 Calling GetInterface method for the CorRuntimeHost interface.
15:23:32 0456 Success.
15:23:32 0456 Starting CLR...
15:23:32 0456 Success.
15:23:32 0456 Getting the CLR version.
15:23:32 0456 The CLR v4.0.30319 has been initialized successfully.
15:23:32 0456 Creating a new domain setup.
15:23:32 0456 Success.
15:23:32 0456 The 'shadow copy' is disabled.
15:23:32 0456 Creating a new application domain.
15:23:32 0456 Success.
15:23:32 0456 Getting the base directory for the domain.
15:23:32 0456 Success. The directory is 'C:Program FilesTestProgram'.
15:23:32 0456 Searching for the Add-in Express core library.
15:23:32 0456 Success. The 'AddinExpress.MSO.2005.dll' file is found.
15:23:32 0456 Creating an instance of the 'AddinExpress.Deployment.ADXRegistrator' class.
15:23:32 0456 Assembly identity is 'AddinExpress.MSO.2005'.
15:23:32 0456 Success.
15:23:32 0456 Unwrapping the instance of the 'AddinExpress.Deployment.ADXRegistrator' class.
15:23:32 0456 Success.
15:23:32 0456 Calling the managed unregistration procedure (DISPID = 1610743823).
15:23:33 0456 Managed Error: 
(Inner Exception)
Date and Time:         12/5/2016 3:23:33 PM
Machine Name:          YUL1DQAWIN1001
IP Address:            fe80::2c92:544:46da:d398%5
Current User:          YUL1DQAWIN1001User

Application Domain:    C:Program FilesTestProgram
Assembly Codebase:     file:///C:/Program Files/TestProgram/MyTest.DLL
Assembly Full Name:    MyTest, Version=3.0.0.27548, Culture=neutral, PublicKeyToken=null
Assembly Version:      3.0.0.27548

Exception Source:      MyTest
Exception Type:        System.ComponentModel.Win32Exception
Exception Message:     The specified module could not be found
Exception Target Site: NewRedemptionObject

---- Stack Trace ----
   Redemption.RedemptionLoader.NewRedemptionObject(guid As Guid)
       RedemptionLoader.cs: line 0221, col 25, IL 0147 (0x93)
   Redemption.RedemptionLoader.new_RDOSession()
       RedemptionLoader.cs: line 0037, col 13, IL 0011 (0xB)
   EVMail.AddinModule.InitRDOSession(withLogon As Boolean)
       AddinModule.cs: line 0815, col 13, IL 0041 (0x29)
   EVMail.AddinModule.UninstallControls()
       AddinModule.cs: line 0597, col 17, IL 0017 (0x11)
   AddinExpress.MSO.ADXAddinModule.ADXUnregister(t As Type)
       MyTest.DLL: N 0563 (0x233) IL 
   EVMail.AddinModule.AddinUnregister(t As Type)
       AddinModule.cs: line 0589, col 13, IL 0001 (0x1)



(Outer Exception)
Date and Time:         12/5/2016 3:23:33 PM
Machine Name:          YUL1DQAWIN1001
IP Address:            fe80::2c92:544:46da:d398%5
Current User:          YUL1DQAWIN1001User

Application Domain:    C:Program FilesTestProgram
Assembly Codebase:     file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
Assembly Full Name:    mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Assembly Version:      4.0.0.0

Exception Source:      mscorlib
Exception Type:        System.Reflection.TargetInvocationException
Exception Message:     Exception has been thrown by the target of an invocation.
Exception Target Site: InvokeMethod

---- Stack Trace ----
   System.RuntimeMethodHandle.InvokeMethod(target As Object, arguments As Object[], sig As Signature, constructor As Boolean)
       mscorlib.dll: N 00000 (0x0) JIT 
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(obj As Object, parameters As Object[], arguments As Object[])
       mscorlib.dll: N 0022 (0x16) IL 
   System.Reflection.RuntimeMethodInfo.Invoke(obj As Object, invokeAttr As BindingFlags, binder As Binder, parameters As Object[], culture As CultureInfo)
       mscorlib.dll: N 0085 (0x55) IL 
   AddinExpress.Projects.Common.Utilities.CallUserDefinedRegistrationMethod(rootKey As ADXRegistryKey, type As Type, bRegister As Boolean, targetHive As ADXTargetRegistryHive)
       mscorlib.dll: N 0332 (0x14C) IL 
   AddinExpress.Projects.Common.Utilities.UnregisterType(t As Type, allUsers As Boolean, targetHive As ADXTargetRegistryHive, callUnregMethod As Boolean, removeProgID As Boolean)
       mscorlib.dll: N 0183 (0xB7) IL 
   AddinExpress.Projects.Common.Utilities.UnregisterAssembly(assembly As Assembly, allUsers As Boolean, targetHive As ADXTargetRegistryHive, callRegMethod As Boolean, removeProgID As Boolean)
       mscorlib.dll: N 0040 (0x28) IL 
   AddinExpress.Deployment.AddinDomainAdapter.RegisterForComInterop(register As Boolean, dllType As String, dllPath As String, showExceptions As Boolean)
       mscorlib.dll: N 0329 (0x149) IL 
   AddinExpress.Deployment.ADXRegistrator.RegisterAssembly(commandLine As String)
       mscorlib.dll: N 0818 (0x332) IL 



15:23:33 0456 The add-in unregistration process is completed with HRESULT = -2147467259.
Posted 05 Dec, 2016 15:51:53 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Hello Eric,

The problem is caused either by your code that you added to the constructor of the add-in module or by an initializer of a complex-type variable declared on the class level of the add-in module. You need to move that code to an event of the add-in module; typically developers use the OnRibbonBeforeCreate event (in an Outlook add-in, it may fire several times) or the AddinInitialize event of the add-in module.

An example of the initalizer is:

MyType myVar = null;

You need to replace this with

MyType myVar;

Then you need to initialize the variable in the event of your choice.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Dec, 2016 04:55:49 Top
developer_cp




Posts: 48
Joined: 2016-10-28
But all my complex-type variable is already as you described.


    public class AddinModule : AddinExpress.MSO.ADXAddinModule
    {   
        private static Logger logger;
       
        private EncryptedMailItemHandler encryptedMailHandler;

        private ADXOutlookAppEvents adxOutlookEvents;
        private BackgroundWorker mailSyncWorker;
        
        private ADXOlFormsManager TrustValidatorFormManager;
        private ADXOlFormsCollectionItem adxOlFormsCollectionItem1;
        private ImageList imageList16x16;
        private ImageList imageList32x32;
        private ADXOlFormsCollectionItem adxOlFormsCollectionItem2;
        private ADXRibbonTab TrustValidatorRibbon;
        private ADXRibbonTab InspectorRibbon;
        private ADXRibbonGroup InspectorRibbonGroup;
        private ADXRibbonButton adxRibbonButton3;
        private ADXRibbonButton InspectorButton;
        private ADXRibbonButton InspectorSupportButton;
        private ADXRibbonButton InspectorVersionButton;
        private ADXRibbonLabel adxRibbonLabel1;
        private ADXRibbonLabel adxRibbonLabel2;
        private ADXRibbonSeparator InspectorRibbonSeparator1;
        private ADXRibbonButton SettingsButton;
        private ADXOlExplorerMainMenu adxOlExplorerMainMenuOL2007;
        private ADXCommandBarButton adxCBBOL2007About;
        private ADXCommandBarButton adxCBBOL2007Settings;
        
        private static Test.Configuration.Settings currentSettings;
        private ModifySettings modifySettings;
       
        private ADXRibbonGroup InspectorRibbonGroupDev;
        private ADXRibbonButton InspectorValidateThis;
        private ADXRibbonButton InspectorCleanThis;

        
        public AddinModule()
        {
            InitializeComponent();
        }

        ...
    }
Posted 06 Dec, 2016 13:22:16 Top
developer_cp




Posts: 48
Joined: 2016-10-28
Is my uninstall code correct? One thing i noticed is that, UninstallControls get called twice for some reason, and I need to put that static variable to make it execute only once.


        private static bool uninstalling = false;
        public override void UninstallControls()
        {
            if (!uninstalling)
            {
                uninstalling = true;
                InitRDOSession(true); // this is where it end up loading the 32bit redemption

                try
                {
                    CleanupForm form = new CleanupForm();
                    form.ShowDialog();
                    form.Close();
                    form.Dispose();

                }
                catch (System.Exception ex)
                {
                    logger.Ex(ex);
                }
            }
        }
Posted 06 Dec, 2016 13:25:42 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Hello Eric,

I'm sorry for misleading you.

The ADXAddinModule.UninstallControls method is invoked by adxregistrator.exe when it creates your add-in module to unregister your add-in. Note that this occurs outside of the Outlook (= host application of your add-in) process.

If you handle the BeforeUninstallControls and/or AfterUninstallControls events of the add-in module, the original UninstallControls will start the host application and invoke the event(s) passing them the application object.

With the code above, there's no Outlook running when your code executes and this causes "The specified module could not be found".

That the 32bit redemption loader is invoked is caused by the fact that adxregistrator.exe is a 32bit application.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Dec, 2016 08:15:23 Top