I am attempting to write a c# script that performs work on an excel spreadsheet. (Rather then a VBA macro). I am trying to add the reference to the Microsoft.Office.Interop.Excel assembly. I cannot find any reference to said assembly in the Add Reference... Window or by browsing to C:\Windows\assembly\GAC. It does not exist. I uninstalled and reinstalled office, and I also downloaded and installed the PIA redistributable located here. The Microsoft.Office.Core is the closest assembly I found, added via COM -> Microsoft Office 14 / 15 Object Library. Any comments or advice appreciated.
I see a copy under C:\Windows\assembly\GAC_MSIL. Is it there for you?
If that doesn't work, open Windows Command Processor and use
dir /s microsoft.office.interop.excel.*
In my C# project, the path is
C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\14.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll
I am using Excel 2010
You might want to have a look at a related post.
Related
Ok now i will try to explain my problem as much as possible. I want to use popular compression algorithm 7zip at my c# project
There is already NuGet package for 7zip
Now when i install 7zip page https://www.nuget.org/packages/SevenZipSharp/0.64.0 it installs fine however it gives error when i try to run
An unhandled exception of type 'SevenZip.SevenZipLibraryException' occurred in SevenZipSharp.dll
Additional information: Can not load 7-zip library or internal COM error! Message: failed to load library
So i decide to add dll file manually and i get this error below
---------------------------
Microsoft Visual Studio
---------------------------
A reference to 'D:\51_doktora tez projesi\program_crawler\doktora_tez_projesi_crawler_program\ExternalDLLs\7z_9_38_2015_01_03.dll' could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
---------------------------
OK
---------------------------
Ok but i found a solution and it works that way
First install nuget package
And before start calling functions set path
SevenZip.SevenZipExtractor.SetLibraryPath("SevenZipSharp.dll");
SevenZip.SevenZipCompressor.SetLibraryPath("SevenZipSharp.dll");
Ok second question which is also interesting
I wanted to use latest version of 7zip DLL file. So downloaded it from official website : https://sourceforge.net/projects/sevenzip/files/7-Zip/9.38/
Downloaded MSI installed and got 64bit dll file. However when i try to reference this file, it fails with error message above: Please make sure that the file is accessible, and that it is a valid assembly or COM component.
However the trick works again
I install NuGet 7zip package. Then before calling functions i set these 2 lines of code and it uses latest version of DLL file
SevenZip.SevenZipExtractor.SetLibraryPath("ExternalDLLs/7z_9_38_2015_01_03.dll");
SevenZip.SevenZipCompressor.SetLibraryPath("ExternalDLLs/7z_9_38_2015_01_03.dll");
So i am looking for answers why all these happens? Why i can not directly add as a reference the DLL file however the trick works?
windows 8.1 64bit, Visual Studio 2013 update 3 WPF application
Part of your problem most likely stems from the fact that SevenZipSharp is merely a wrapper for the 7z.dll, which to the best of my knowledge is a c++ dll. The project page, for SevenZipSharp, also mentions that any compatible dll can be used and needs to be specified:
SevenZipSharp requires a 7-zip native library to function. You can specify the path to a 7-zip dll (7z.dll, 7za.dll, etc.) in LibraryManager.cs at compile time, your app.config or via SetLibraryPath() method at runtime. + "7z.dll" is the default path. For 64-bit systems, you must use the 64-bit versions of those libraries.
7-zip ships with 7z.dll, which is used for all archive operations (usually it is "Program Files\7-Zip\7z.dll"). 7za.dll is a light version of 7z.dll, it supports only 7zip archives. You may even build your own library with formats you want from 7-zip sources. SevenZipSharp will work with them all.
I'm working on a windows form application which Visual Studio 2008.
Recently I added to my project the "Microsoft.Office.Interop.Excel.dll". However, when I looked in the bin folder, after build the project, the following files have been added beyond the dll:
Microsoft.Office.Interop.Excel.xml
Microsoft.Vbe.Interop.dll
Office.dll
office.xml
My team asked me why these files were added, an I not knew how answer. Someone have a nice explanation for this?
Thanks in advance.
Those are the "Primary Interop Assemblies" and are required:
Some assemblies are added to a project automatically when an assembly that references them is added. For example, references to the Office.dll and Microsoft.Vbe.Interop.dll assemblies are added automatically when you add a reference to the Word, Excel, Outlook, Microsoft Forms, or Graph assemblies.
This shouldn't be difficult, but I can't add HtmlAgilityPack.dll as a reference in an empty C# project. Here is what I did:
Downloaded HtmlAgilityPack.1.4.5.zip.
Unzipped it.
In the Solution Explorer, I right-clicked on References and selected 'Add Reference...'.
I use Visual Studio 2008 and selected Net20/HtmlAgilityPack.dll.
There is now a yellow triangle on the HtmlAgilityPack.dll and I can't edit the path in its properties. If I remove it and add it again, the same thing happens. What am I doing wrong?
I had the same problem with 1.4.5, try to download the 1.4.0 version.
http://htmlagilitypack.codeplex.com/releases/view/44954
I'm not sure why it doesn't work, but if you look at here you will see others with the same problem.
Quoting ttraguth:
Hi,
I have the same problem here integrating the current 1.45 binaries in
an .NET 3.5 Application.
dotPeek also shows the assembly as 4.0.
Maybe your .targets broke?
I know this isn't a programming question but it is a programming tool question.
In Visual Studio 2008 Team Edition (version 9.0 with .NET 3.5 SP1) when I copy and paste references from one csproj to another (with the context menu in the 'Solution Explorer' view) I get the following error:
Error HRESULT E_FAIL has been returned from a call to a COM component
This has only just started happening on my machine. I can only find this article about it, and it contains no solution.
Any ideas?
This is the #1 hit that shows up on Google for VS 2010 paste reference E_FAIL and the like, so I thought I would share this workaround:
Don't use copy/paste references via the context menu in Solution Explorer.
Instead:
Use the context menu to unload the project to copy references from.
Edit the project file (.csproj; it's just XML).
Find the
reference(s) you are interested in and copy the <Reference> XML
node(s).
Unload the project to copy the reference into.
Edit the project file (.csproj)
Paste the reference copied in the previous step into appropriate location. You need to look for
the <ItemGroup> node containing something like <Reference Include="mscorlib" />, and paste your reference just above it.
Close both .csproj files, saving the just-modified target one as well.
Reload both projects via Solution Explorer context-menu.
Your reference is now copied into the target project.
Apparently, at the very minimum, there is a problem with references that use environment variables, as described here (although in my case, I was having a problem with references that did not use environment variables, and in Visual Studio 2010...)
Yikes , E_FAIL is the most generic COM error , since it literally means a COM function returned fail. I would guess that somehow , visual studio 2008 has a corrupted COM object somewhere.
Have you tried reinstalling visual studio 2008 just to get it to re-register all its tlb's and objects ?
I have a Visual Studio 2008 project that has a reference to a dll. I removed the reference to version 1 and added a new reference to version 2. The project builds successfully, however when I analyze the project dll after it has been built in Reflector I am seeing that it is holding onto two references to the same dll - version 1 and version 2 are both referenced.
If you look at your project file in notepad, can you see both references in there? You may have to scan through a bit of xml to find them... If so, you could manually remove the old one and resave the project in notepad.
go to Property pages and remove it easily