Could not load file or assembly 'Microsoft.Office.Interop.Excel'
I have a program that reads data from excel.
I use:
Imports Microsoft.Office.Interop
as well as a Reference from the "COM" tab called "Microsoft Excel 11.0 Object Library"
I built my program then copied the .exe from the \bin\Debug folder to a location on my company's server. I then double clicked the .exe and it ran as I expected it would.
My boss then tried (from another computer) and he gets this error:
Code:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
at timesheetGUI.Form1.PopulateCheckBoxArea()
at timesheetGUI.Form1.bttnScanWorksheets_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3603 (GDR.050727-3600)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
timesheetGUI
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Documents%20and%20Settings/rwood/Desktop/Temp/Timesheet/timesheetGUI.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
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.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3082 (QFE.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Could someone explain why it works for me and not him? I am new to references but I feel that the problem is there.
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
Just ship the office dll with the exe...
*EDIT* - The dll should be in the Debug\Release folder
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
No... the problem was your deployment process... you have the MS Office Interop files installed. Your boss doesn't. Look back in the bin folder.... look for other DLLs see if they are in there.
I think what you need are the PIAs... as described in this trhead:
http://www.vbforums.com/showthread.p...&highlight=PIA
Or better yet - we have an entry in the FAQ : http://www.vbforums.com/showthread.p...&highlight=PIA
-tg
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
Quote:
Originally Posted by
mickey_pt
Just ship the office dll with the exe...
*EDIT* - The dll should be in the Debug\Release folder
There is no dll files there.
edit: this is not a webserver, just a file server.
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
doesn't matter... you still need the PIAs on the computer that is running the app... in the threads I linked to (well the first one), they were doing some stuff on the server side, which is why they need to be installed on the webserver.
In your case, the users are going to need Office installed, then the PIAs installed (since it wasn't in the bin directory, it's possible the PIA files were installed into the GAC).
-tg
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
@techgnome
Maybe yes and maybe not
I have the same problem with an application, just shipped the wrong version of the assembly and i had an error similar to this one...
And i'm assuming that the computer all have the ms office installed.
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
Quote:
Originally Posted by
techgnome
doesn't matter... you still need the PIAs on the computer that is running the app... in the threads I linked to (well the first one), they were doing some stuff on the server side, which is why they need to be installed on the webserver.
In your case, the users are going to need Office installed, then the PIAs installed (since it wasn't in the bin directory, it's possible the PIA files were installed into the GAC).
-tg
I don't know if it will be possible to install the PIA's on every computer running the app. I will need to include it with the app.
If I look under my references, and choose properties for the excel one I get the path as this:
C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Excel\11.0.0.0__71e9bce111e9429c\Microsoft.Office.I nterop.Excel.dll
It would be nice if I could edit that so it is just:
Microsoft.Office.Interop.Excel.dll
and then I throw that dll in the folder with my app.
The problem is the path seems to be read only, and in explorer there is no GAC folder.
Quote:
Originally Posted by
mickey_pt
And i'm assuming that the computer all have the ms office installed.
Yes, you can assume that.
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
Are you using the installer, or xcopy?
You can try to copy directly that dll to the application folder.
Why do you added the COM version?
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
Quote:
Originally Posted by
mickey_pt
Are you using the installer, or xcopy?
You can try to copy directly that dll to the application folder.
Why do you added the COM version?
I use the COM version cause thats what I read I needed and there is no .NET version.
Not sure what you mean by installer or xcopy.
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
Quote:
Imports Microsoft.Office.Interop
as well as a Reference from the "COM" tab called "Microsoft Excel 11.0 Object Library"
Remove the COM reference and add the same reference but this time in the NET references, then compile your application, and then you should see a new dll file in the debug/release folder.
Installer it's a Setup Project (MSI File)
XCopy, just copy the files directly without any kind of setup.
BTW, what VS version are you using?
In 2008 version you can found the references here, default installation directory C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
Quote:
Originally Posted by
mickey_pt
Remove the COM reference and add the same reference but this time in the NET references, then compile your application, and then you should see a new dll file in the debug/release folder.
Installer it's a Setup Project (MSI File)
XCopy, just copy the files directly without any kind of setup.
BTW, what VS version are you using?
In 2008 version you can found the references here, default installation directory C:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11
When I go projects-> add reference there is no "Microsoft Excel 11.0 Object Library" under the ".NET" tab.
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
what version of vs are you using? Express edition?
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
Quote:
Originally Posted by
mickey_pt
what version of vs are you using? Express edition?
2008 express.
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
That's why you don't have the .NET version...
So then your application run in your computer and in the server, so the problem must be in your boss pc, the version isn't the same or he/she doesn't have any office...
Download and install the PIA for Office
Additional info:
MSDN
GAC
Re: Could not load file or assembly 'Microsoft.Office.Interop.Excel'
Quote:
Originally Posted by
mickey_pt
That's why you don't have the .NET version...
So then your application run in your computer and in the server, so the problem must be in your boss pc, the version isn't the same or he/she doesn't have any office...
Download and install the PIA for Office
Additional info:
MSDN
GAC
Thanks, that seemed to work. My boss has the same Office products installed as me, so is there any other reason why it didn't work for him?