none
Can't Debug Excel Add-In RRS feed

  • Question

  • I'm trying to set up my development environment to be able to develop add-ins for Excel. I've followed a few tutorials and my code compiles without errors, but when I go into debug mode to try and test my add-in, I keep getting the same error noted below.

    I'm running on Windows 7 Enterprise, Visual Studio 2010, .NET Framework 4.0, developing add-ins for Excel 2007. Error text:

    Could not load file or assembly 'TestAddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.


    ************** Exception Text **************
    System.IO.FileLoadException: Could not load file or assembly 'TestAddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

    Access is denied.
    File name: 'TestAddIn, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> System.IO.FileLoadException: Could not load file or assembly 'TestAddIn,

    Version=1.0.0.0, Culture=neutral' or one of its dependencies. Access is denied.
    File name: 'TestAddIn, Version=1.0.0.0, Culture=neutral'

    === Pre-bind state information ===
    LOG: User = ACCT04\u90854
    LOG: DisplayName = TestAddIn, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
     (Partial)
    WRN: Partial binding information was supplied for an assembly:
    WRN: Assembly Name: TestAddIn, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL | Domain ID: 2
    WRN: A partial bind occurs when only part of the assembly display name is provided.
    WRN: This might result in the binder loading an incorrect assembly.
    WRN: It is recommended to provide a fully specified textual identity for the assembly,
    WRN: that consists of the simple name, version, culture, and public key token.
    WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
    LOG: Appbase = file:///C:/Users/u90854/Documents/Visual Studio 2010/Projects/TestAddIn/TestAddIn/bin/Debug/
    LOG: Initial PrivatePath = NULL
    Calling assembly : (Unknown).
    ===
    LOG: This bind starts in default load context.
    LOG: No application configuration file found.
    LOG: Using host configuration file:
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
    LOG: Attempting download of new URL file:///C:/Users/u90854/Documents/Visual Studio 2010/Projects/TestAddIn/TestAddIn/bin/Debug/TestAddIn.DLL.
    LOG: No application configuration file found.
    LOG: Using host configuration file:
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
    ERR: Failed to complete setup of assembly (hr = 0x80070005). Probing terminated.

       at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,

    StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,

    StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean

    forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
       at System.Reflection.Assembly.Load(String assemblyString)
       at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.CreateEntryPoint(String entryPointTypeName)
       at

    Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.Loa

    dEntryPoints(IntPtr serviceProvider)




    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.239 (RTMGDR.030319-2300)
        CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    ----------------------------------------
    Microsoft.VisualStudio.Tools.Office.Runtime
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.31119.0
        CodeBase:

    file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Office.Runtime/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.O

    ffice.Runtime.dll
    ----------------------------------------
    System.Core
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.225 built by: RTMGDR
        CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
    ----------------------------------------
    System
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.258 built by: RTMGDR
        CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Configuration
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
        CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    ----------------------------------------
    System.Xml
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.225 built by: RTMGDR
        CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    System.Security
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
        CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Security/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Security.dll
    ----------------------------------------
    Microsoft.VisualStudio.Tools.Applications.Hosting
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.31119.0
        CodeBase:

    file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Hosting/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.T

    ools.Applications.Hosting.dll
    ----------------------------------------
    Microsoft.VisualStudio.Tools.Applications.Runtime
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.31119.0
        CodeBase:

    file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.T

    ools.Applications.Runtime.dll
    ----------------------------------------
    System.Deployment
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
        CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Deployment/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Deployment.dll
    ----------------------------------------
    Microsoft.VisualStudio.Tools.Applications.ServerDocument
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.31119.0
        CodeBase:

    file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.ServerDocument/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualS

    tudio.Tools.Applications.ServerDocument.dll
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.235 built by: RTMGDR
        CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System.Xml.Linq
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
    ----------------------------------------
    Microsoft.Office.Tools
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.31119.0
        CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.dll
    ----------------------------------------
    Microsoft.Office.Tools.Excel.Implementation
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.31119.0
        CodeBase:

    file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools.Excel.Implementation/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Excel.I

    mplementation.dll
    ----------------------------------------
    Microsoft.Office.Tools.Common.Implementation
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.31119.0
        CodeBase:

    file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools.Common.Implementation/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Common

    .Implementation.dll
    ----------------------------------------
    Microsoft.Office.Tools.Common
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.31119.0
        CodeBase:

    file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools.Common/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Common.dll
    ----------------------------------------
    Microsoft.Office.Tools.Excel
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.31119.0
        CodeBase:

    file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Office.Tools.Excel/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Excel.dll
    ----------------------------------------

    I've tried looking around on Google for a solution and nothing seems to work. Any help you can provide would be much appreciated. Thank You!

    Tuesday, March 13, 2012 5:33 PM

All replies

  • open up process monitor http://technet.microsoft.com/en-us/sysinternals/bb896645 and start your excel/add-in again. Now look in process monitor for access_denied results of action - which file has it?
    Wednesday, March 14, 2012 8:53 AM
  • Damian,

    Thanks for your response. I've run process monitor, but there are no "access_denied" results coming up. I've applied a few filters so that I'm only seeing results from my Excel and Visual Studio processes that ARE NOT successful, but no "access_denied" results or anything similar are appearing. The closest thing to it are some "NAME NOT FOUND", "FILE LOCKED WITH ONLY READERS", and "PATH NOT FOUND" results.

    Any suggestions?

    Wednesday, March 14, 2012 1:47 PM
  • Hard to tell

    to cut out the noise, write console app that will do the same as VSTO:

    System.Reflection.Assembly.LoadWithPartialName("'TestAddIn")

    place it in add-in output dir, set filter in process monitor to name of your console app and run it. It should also generate access denied exception (hopefully) and you should see only files that are relevant. Maybe there you will be able to see which file is locked.

    Wednesday, March 14, 2012 2:08 PM
  • I made a console app called ErrorTest and tried running it in a few different locations including the TestAddIn's publish folder where the setup.exe and the TestAddIn.vsto files are as well as the main TestAddIn folder where TestAddIn.sln resides. In both cases I got the same:

    Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'TestAddIn' or one of its dependencies. The system cannot find the file specified

    This generated a number of processes caught by Process Monitor, but none of them was an access denied result. I received a number of "FILE LOCKED WITH ONLY READERS", "NAME NOT FOUND", "REPARSE", and "NO SUCH FILE" results, but nothing about access denied.

    The System.IO.FileNotFoundException makes me think that it isn't even properly loading TestAddIn. Is that true? If so, what directory am I supposed to run the console app from? Also, just to make sure I'm not missing anything, the code for my console app is:

    Module Module1

        Sub Main()       
            System.Reflection.Assembly.Load("TestAddIn")
        End Sub

    End Module

    I used Assembly.Load because VS told me LoadWithPartialName has been deprecated.

    Thanks,

    Wednesday, March 14, 2012 5:14 PM
  • Hi blear53184,

    Thanks for posting in the MSDN Forum.

    It's based on my experience this add-in exists and it was working before you try to debug it. And I think we need consider whether Anti-Virus software affect your add-in.

    I hope it can help you.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, March 15, 2012 5:34 AM
    Moderator
  • Just to be sure that no other process accesses your files, copy output dir with your add-in dlls and dependencies (and also console app) to different location (just copy and paste) and run console app from there - if you get the same error, open up process explorer (http://technet.microsoft.com/en-us/sysinternals/bb896653), click Find-> handle or dll and one by one enter names of your dlls that are in your folder with add-in - and see if some process is accessing them. Maybe this is like Tom said - your antyvir is blocking some files.
    Thursday, March 15, 2012 8:11 AM
  • Thanks for all the feedback so far everyone. I was doing some research and I'm afraid it may be the Antivirus thing. I ran this same project file on my home computer with the same OS, Visual Studio version. .Net framework, and same version of Office and the add-in worked just fine. I've read a number of articles that suggest my company may have rules in place to prevent Microsoft Office from creating .dll or other important files. As far as I can tell, this function is called "shadow copy" and there is no way to disable it within Visual Studio. Anyone know a work around for this?

    Damian, I will try your latest suggestion and see if I get any different results.

    Thank You,

    Thursday, March 15, 2012 5:41 PM
  • Hi blear53184,

    Did you trid Damian's suggestion? And would you please tell me the result?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, March 19, 2012 6:53 AM
    Moderator
  • Sorry it took so long to respond. I did try what Damian suggested, but I'm not 100% sure I am doing what he suggests. I moved my add-in files and the console app to a folder on my desktop and tried running the console app again and got the same System.IO.FileNotFoundException. I downloaded process explorer and had that open as well and couldn't find anything trying to use TestAddIn.dll.

    At this point I'm going to assume it's the antivirus software that is keeping me from being able to debug my add in. Does anyone know of a way to verify if McAfee is indeed interfering?

    Thanks,

    Wednesday, March 21, 2012 2:17 PM
  • Previously you got Access Denied, not FileNotFound, make sure you copied all dlls/dependencies to separate folder, not only one dll.
    Wednesday, March 21, 2012 2:30 PM
  • The FileNotFound error was what I got once I tried the console app. Does that mean my console app isn't working correctly?
    Wednesday, March 21, 2012 3:15 PM
  • most probably it means that some dependency (other dll) was not found when Fusion was loading dll into memory, as this should be verbatim copy of output folder which exhibits access denied problem, i assume that something was not copied over to new location and hence file not found problem.
    Wednesday, March 21, 2012 9:13 PM
  • All,

    I just wanted you give you a heads up that I think the antivirus software at my company was what was causing the problem. I got a separate development laptop that doesn't have the antivirus restrictions on it and my test add-in works just fine.

    I want to thank all of you for your efforts, they really were critical in helping me nail down what the issue was.

    Thanks!

    • Proposed as answer by Bruce Song Wednesday, April 4, 2012 6:27 AM
    Tuesday, March 27, 2012 2:40 PM
  • great, close the thread :-)
    Tuesday, March 27, 2012 2:56 PM