index > Visual Studio Tools for Office > "Office document customization is not available" error

"Office document customization is not available" error


This error happens very frequently when an Excel VSTO project is built and run within VS. The Excel file will open, but this error will occur.

The way I deal with it is to close the Excel file and restart it within VS again, or and again, or and again, or and again, .... The error usually will disappear after rerunning the application once, or twice, or thrice, ... Sometimes, I do have to close VS and restart the whole thing.

Could anyone offer a better remedy?

I am using the latest versions of VS and VSTO.

The details of the eroor are copied as following:

Could not load file or assembly 'AB5000Trend, Version=1.0.2309.22694, Culture=neutral' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)


************** Exception Text **************
System.IO.FileLoadException: Could not load file or assembly 'AB5000Trend, Version=1.0.2309.22694, Culture=neutral' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)
File name: 'AB5000Trend, Version=1.0.2309.22694, Culture=neutral'
at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.HandleOnlineOffline(Exception e, String basePath, String filePath)
at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadStartupAssembly(EntryPoint entryPoint, Dependency dependency, Dictionary`2 assembliesHash)
at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ConfigureAppDomain()
at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadAssembliesAndConfigureAppDomain(IHostServiceProvider serviceProvider)
at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ExecuteCustomization(IHostServiceProvider serviceProvider)

=== Pre-bind state information ===
LOG: User = ABIOMED.COM\hzhang
LOG: DisplayName = AB5000Trend, Version=1.0.2309.22694, Culture=neutral
(Partial)
LOG: Appbase =
file:///C:/Documents and Settings/hzhang/My Documents/Software Projects/VSNET/Office/AB5000Trend/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Microsoft.VisualStudio.Tools.Applications.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\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:/Documents and Settings/hzhang/My Documents/Software Projects/VSNET/Office/AB5000Trend/bin/Debug/AB5000Trend.DLL.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\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 = 0x80070020). Probing terminated.

************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Microsoft.VisualStudio.Tools.Applications.Runtime
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.42
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.dll
----------------------------------------
Microsoft.Office.Tools.Common
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.42
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.Office.Tools.Common/8.0.0.0__b03f5f7f11d50a3a/Microsoft.Office.Tools.Common.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------




hz
hipswich
Sometimes that will happen to me after I have thrashed the office Com compenents with multiple runs after it throws exception that are generated within my code. Do a divide an conquer approach by isolating portions of your code until the loading failure goes away consistently. Or try to put more of the code within try/catch blocks.

The question is, does this happen if you create a fresh VSTO project with no code in it?
OmegaMan

Hi,

I am not sure exactly what is causing this error. But as the error message says some process is using the AB5000.dll file and has it locked.

Is it possible that VS is still compiling this dll when Excel is launched? Accordingly to folks I have talked to this is very unlikely. VS would only lauch Excel once the dll is compiled.

Is it possible that some "left-over" instance of Excel is using the dll? No. Excel loads the VSTO assembly by making a copy of it (search for .NET appdomain ShadowCopy behavior).

Are you running an executable in a post-build step that might be using the file?

I would suggest you download Process Explorer tool from SysInternals website:
http://www.sysinternals.com/Utilities/ProcessExplorer.html

This is a great tool if you don't have it. Click Handle menu and type the "AB5000.dll" in the textbox and you get a list of processes with handle to the file. You can run your VSTO customization from VS and when you get the error message start Process Explorer. Hopefully, you can find the process(es) that has the file handle open. Please let us know what you find.

Thanks




Apurva Sinha
Apurva Sinha - MSFT

Hi, thanks for all the suggestions.

1. I build the applications first, then run them, so it is impossible the compiling is still going on.

2. I start the applications only from VS.

3. I downloaded Process Exlorer and am running it now. The Handle menu is grayed. I used Find Handle or Dll and typed AB5000.dll and could not find anything.

I am still using the method of repeating restaring the application. Usually after 7 or 8 times, the error message will be gone. I have also noticed that if I swtich the build mode (e.g. from debug to release, or vice versa), it may accelerate the disappearance of the error message.




hz
hipswich
Have you tried removing items as suggested in my previous post?

Also I have had assembly load failure when I do things on a sheet startup like subscribe to an event using a dynamic method signature on a object that does not exist at that time...boom, but no exception caught by Excel, just the load failure.
OmegaMan

Hi, thanks for all the information.

The way my applications work is this:

There is a button called "Compute" on each wroksheet. There is no code for Sheet??_Startup(). My code is run only the button is clicked. In other words, I get the error before any of my code is executed. Therefore I doubt that the error has anything to do with my code. Very annoying.

hz




hz
hipswich

I don't think the error has anything to do with your code either. Because it happens much before the startup event is fired.

I think some process is definitely using the assembly file and thus has it locked. So, the VSTO loader fails to load the assembly. Neither VS nor the loader should be doing this. So, it's hard for me to say which process it the culprit.

1. Just to check, please give some details on the version of VS, VSTO and runtime you have installed?

2. Have you specified a post build step (e.g. an executable) in your project file?

3. Does this error only occur for one specific Excel project or for all Excel VSTO projects?

4. Can you create a new blank Excel VSTO project and see if the error occurs there

5. Do you also see the error when debugging Word VSTO projects?

6. What kind of machine configuration do you have?

Thanks




Apurva Sinha
Apurva Sinha - MSFT

Hi I am still struggling with this error.

1. I am using the latest version of VS, VSTO received from MSDN subscription (last December?).

2. I am not sure what you mean by post build step.

3. It occurs on multiple Excel projects.

4. I have just created a new VSTO project and run it a few times and this error did not occur. However, the error is not predictable. It does not occur if I start everything fresh (e.g. rebooted my computer). It occurs usually after the VSTO application is run from within VS a few times.

5. I have never had a Word VSTO project.

6. I have a Dell Dimension 370 with P4 3.0 GHz and 2 GB RAM.

Thanks,

hz




hz
hipswich

Hi Apurva,

I have seen your post in the forum. I am also facing the same problem. My problems are...

1. Even if I create a new ExcelWorkbook project using C#. Immediately after creationg without adding any new code if I run it....Excel application is opened but the following error is showing...

"The customization assembly could not be found or could not be loaded. Yo can still edit and save the document. Contact your asministrator or the author of this document for further assistance."

2. I am using Visual Studio 2005. Microsoft Office 2003. Visual Studio Tools for Office 2005.

I can't run it for a single time.

It will be of immence help, if you could give some idea to how to bypass this kind of problem.

Saibal

Note : One thing I think I should mention here. Recently I have Updated my machine from Windows 2000 professional to Windows XP without formating my machine.




Dot Net (C#) Developer
Saibal Goswami

Thanks for the tips! I am sorry for delayed response.

Let me report an observation that may be a good lead before I try to answer the questions. I noticed that the error happens when I have two instances of VS open (I like to have two open so I can work on two unrelated solutions). It seems the error disppears when I close the other instance of VS with non-office application solution. I have not had that error when I have only one VS open. The error happened again, though not immediately, after I started another instance of VS. Since I have not tried this many times to verify this, I cannot gurantee this is 100% repeatable, but I will continue my observation and post it here if I see anything contradictory.

Does this mean anything?

hz




hz
hipswich

I am not sure but it seems like the problem is related. I regularly have many instances of VS open but I have never seen this issue personally.

Does the non-Office project open in the other instance of VS reference the VSTO customization assembly or one of the dependencies of the VSTO assembly?

Do you have any addins for VS that may be causing the problem?

Thanks




Apurva Sinha
Apurva Sinha - MSFT

Yes, almost every one of my projects in C# references a project called CSCommon that is essentially a collection of frequently used functions of all kinds such as computing average, standard deviation, Fisher-exact tests, etc. However that project has not been touched for a while.

All the projects use Serena ChangeMan for source control. I do not know if this is the type of addins you referred to.

hz




hz
hipswich

Hi,

Have you been able to resolve this issue.

Thanks.

Naveen Yajaman - MSFT

Hello,

Unfortunately I have not.

I have found that multiple instances of VS are not the cause of the problem. It seems that many things related to VS can be done to make the error disappear temporarily - switching build mode from debug to release, or vice versa, starting or stopping the VSTO application multiple times, closing another instance of VS, or closing and reopening the current instance of VS. Doing these things to deal with the error has become a part of my daily life.

hz




hz
hipswich

hz,

In a previous post when you ran process explorer you searched for "AB5000.dll". The assembly actually being locked is "AB5000Trend.dll". It really does sound like some process has AB5000Trend.dll locked and we need to determine what process it is. Perhaps you made a typo and actually did look for "AB5000Trend.dll" but I'd like to make sure.

Thanks.

Jeff Young - MSFT

Hi, I am sorry for getting back late and thanks for your attention.

Yes, you are right that I had a typo.

I used Process Explorer and found two entries both of which are devenv.exe.

PE does not allow me to copy the entries in text, but I captured as image. Is there anyway I can attach that image file this post because I believe the contents are quite telling.

hz




hz
hipswich

Hi,

You can mail them to me at apsinha at microsoft. I don't know much about Serena but if it loads an in-proc component (i.e. addin) into VS then that component could have causes devenv to lock the file. devenv.exe would appear as the culprit in Process Explorer. You might want to disable that completely and try building projects. Thanks.




Apurva Sinha
Apurva Sinha - MSFT

Hi hz,

Has this issue been resolved? Do you need more help on this?

Thanks.




This posting is provided "AS IS" with no warranties, and confers no rights.
Mohit Gupta - MSFT

No. I still have this problem, but I can live with this.

No software is bug free. I just regard this as a bearable bug of VS, VSTO or Excel.

BTW, quite often Excel still exists in the background after I close everything. I have to use Task Manager to kill the Excel process that prevents me from doing anything with the file it holds.

hz




hz
hipswich
reply 19

You can use google to search for other answers

 

More Articles

powerpoint web display
Setting up an InfoPath Query off of Outlook's Address Book
get_XML
How to Develop InfoPath Application Using MicroSoft.NET InfoPath ...
Word2003/Servlet(JSP)
Two Excel Addin questions
Access Developer Extension
Save worddocument
KB908002 - The 2003 exe redist
Excel object in shared com addin
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

Document-level VSTO in Access 2007
Outlook Addin to Interact With External …
Error opening an excel file with cached …
Rpresenting ranges as nmbers
Email Address of the Current User
Is there any way to have the setup.exe b…
Death at the first hurdle.. cannot even …
Visual Studio (for VSTO) canot find Micr…
tooltips over bookmarks best case
Excel interop problem: Styles with borde…
vsto code
GAC version of Microsoft.ApplicationBloc…
VS 2005 Professional with Office Tools
Required software to install on Web Serv…
Excel cut and paste problem

Hot Articles

(no symbols loaded for any call stack fr…
Intercept events from custom controls
Excel 2003 called from an webservice
How to combine two wordml documents?
Referencing Office XP PIAs
VSTO 2005 Command Bar opening WinForm pr…
OnStartupComplete not firing on client m…
Office 2007 Custom Ribbon
VSTO -- vs. Visual Studio/Basic 2005 Exp…
Excel COM Add-in vs. Managed Automation …
Word 12 Document Project & Ribbon Co…
Depolyment on Office XP is not working
Customizing a Smart Tag menu?
Can I use Actions pane control in my sha…
creating VSTO outlook Addin Setup File

Recommend Articles

tooltips over bookmarks best case
Retrieve cell contents and calculations …
Action Pane disappears
Outlook Appointment Schedule
Selection.PasteExcelTable
Repeating Table Headers in Word 2003
Create manual and automated tests for VS…
Is this possible with VSTO 2005?
Outlook 2003 TaskPane ???
Saving word doc silently
problems with dialogs loaded from ms off…
C++ AddIns 4 MS-Word
protection
Generating New Word Doc from C# Applicat…
NO LUCK plz HElp