none
Add-in created with VS2010 does not load on Excel 2007 on Windows XP RRS feed

  • Question

  • I have run into a similar problem as described in below thread:

    http://social.msdn.microsoft.com/Forums/en-AU/vsto/thread/54915f5e-4ad1-4d51-9e8c-31556fe4c998?prof=required

    I had used Excel Coded UI Tech Provider Sample provided here: http://archive.msdn.microsoft.com/excelCUITechProv/Release/ProjectReleases.aspx?ReleaseId=4049:

    I was able to record and play test cases created with the above in a Windows 7 system that has Visual Studio 2010. Now I use this same sample and open it in a Windows XP SP 3 system. I build this sample in Windows XP box. I followed the build and Install instructions as provided with this sample. When I Click on Test --> Coded UI Test, the CodedUITestBuilder.exe recorder window opens. So far so good. I keep open an Excel 2007 worksheet and click on Start recording to start the recording process. I now click within a cell within the worksheet. Now I run into an error

    CodedUITestBuilder.exe has encountered a problem and needs to close. If I click on debug the Exception message is - Failed to connect to an IPC Port: The system cannot find the file specified.

    After looking at the above thread, I went into the control panel to check that the system has .NET fw versions 2.0 SP2, 3.0 SP2, 3.5 SP 1, 4.0 Client Profile shown in the Add/ Remove programs list. I still went ahead and applied the hot fix. When I ran the hot fix, I got the msg : This fix is already installed on this system.

    Any help to resolve this issue?

     Also, When I go into Excel and check the Excel Options --> Add-ins tab , I find that the Microsoft.VisualStudio.Test.Sample.UI.Excel.Addin is listed in the Inactive Application Add-ins.

    I went into the COM add-ins --> Manage. I find the above add in listed but un checked in the pop up window that shows up. When I highlight this add in : I see the Load Behavior as: Not loaded. A run time error occured during the loading of the COM add in .

    The eventviewer has the following error recorded corresponding to this:

    Microsoft.VisualStudio.Test.Sample.UI.Excel.AddIn.vsto
    Exception: Customization could not be loaded because the application domain could not be created.

    ************** Exception Text **************
    Microsoft.VisualStudio.Tools.Applications.Runtime.CannotCreateCustomizationDomainException: Customization could not be loaded because the application domain could not be created. ---> System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)


    Sudhakar
    Wednesday, July 27, 2011 5:56 AM

Answers

  • Nice to know that the sample addin is loading.  Let's continue talk about its functionality. 

    1) In this case, activex control on Excel workbook, while you click on the button, I guess the UI element you get is still the cell under the button.  Depends on the control type, we may try different kinds of automation technology to get UI element. If it's a typical Win32 control, then we could use Microsoft Active Accessibility(MSAA), which demonstrated in project CodedUIExtensibilitySample, Utilities.cs. Search the window of button by FindWindow, or FindWindowEX(http://www.pinvoke.net/default.aspx/user32/FindWindowEx.html), then call AccessibleObjectFromWindow() to get the object to be automated, then calling accDoDefaultAction against the object could click on it. Control type is key to decide which automation technology apply. WPF or silverlight control is another case. I'm not sure if activex control could be of this type.

    2) Look through the sample, I think the communication channel is established during addin startup, destroyed during addin shutdown. If the channel get corrupted, I would suspect the addin unloaded unexpectedly. If application was forced exit, like kill process, ThisAddin_Shutdown may not execute, this may caused the channel doesn't close gracefully. 

    Please let me know if you figured it out.

    Regards,

     


    Forrest | MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, August 1, 2011 1:39 PM
    Moderator

All replies

  • Hi Sudhakar,

    The Excel Coded UI sample target .NET3.5 and Office 2010, we could see target Office by checking PIA version in project reference.  Given that project targets to .NET 35, addins targets newer Office could not be loaded with older Office, Office 2007 in this case.  You may refer to Mclean Schofield's blog here: http://blogs.msdn.com/b/vsto/archive/2010/06/04/creating-an-add-in-for-office-2007-and-office-2010-that-quot-lights-up-quot-on-office-2010-mclean-schofield.aspx

    In this case, you need Office 2010 to run the sample addin.

    If you do want to use this sample with Office 2007, you may want to retarget project ExcelCodedUIAddinHelper to .NET 40 and install kb976477 if there's ONLY .NET40 on machine.

    Regards,


    Forrest | MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, July 29, 2011 11:27 AM
    Moderator
  • Hi Sudhakar,

    Does the above reply hit the problem?

    Regards,


    Forrest | MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, August 1, 2011 1:16 AM
    Moderator
  • Hi Forrest,

    Not quite. In the sense, Although I have been able to get the basic sample working for me, I am unable to fine tune this sample to meet my requirements. The following are the issues that I am facing:

    1) Once I begin to start a recording - I open an Excel sheet and record some basic actions like , Clicking in cells etc. The identification of worksheet, cell kind of objects is fine.

    Now, I add a ActiveX control button to the Excel sheet. My actual requirement has ActiveX control buttons that run macros. I would like to automate the click of these buttons.

    When I take the crosshair to this button, it doesn't recognize this button. For this I understand the UI project needs to be extended further but I am not sure how to proceed further.

    2) The Remoting based communication channel is getting opened, I believe, when the first time the Excel sheet is being opened. Should I close this Excel sheet by any chance, I have issues with the playback of the recorded test cases. I sense the communication channel is getting corrupted in this case. My expectation is that when the Excel is closed, the Application_Shutdown event should fire in and close the channel gracefully. I feel this is not happening.

    If I resort to this first excel sheet closure, I keep getting the following error msg :

    System.Runtime.Remoting.RemotingException was unhandled  Message=Failed to connect to an IPC Port: The system cannot find the file specified.

    Pl guide me in these problem areas.

    Thanks in advance.

    -Sudhakar


    Sudhakar
    Monday, August 1, 2011 6:55 AM
  • Nice to know that the sample addin is loading.  Let's continue talk about its functionality. 

    1) In this case, activex control on Excel workbook, while you click on the button, I guess the UI element you get is still the cell under the button.  Depends on the control type, we may try different kinds of automation technology to get UI element. If it's a typical Win32 control, then we could use Microsoft Active Accessibility(MSAA), which demonstrated in project CodedUIExtensibilitySample, Utilities.cs. Search the window of button by FindWindow, or FindWindowEX(http://www.pinvoke.net/default.aspx/user32/FindWindowEx.html), then call AccessibleObjectFromWindow() to get the object to be automated, then calling accDoDefaultAction against the object could click on it. Control type is key to decide which automation technology apply. WPF or silverlight control is another case. I'm not sure if activex control could be of this type.

    2) Look through the sample, I think the communication channel is established during addin startup, destroyed during addin shutdown. If the channel get corrupted, I would suspect the addin unloaded unexpectedly. If application was forced exit, like kill process, ThisAddin_Shutdown may not execute, this may caused the channel doesn't close gracefully. 

    Please let me know if you figured it out.

    Regards,

     


    Forrest | MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, August 1, 2011 1:39 PM
    Moderator