I need to make some application to work with MS Word. I read some instruction and there was told, that I need to add Reference to Microsoft.Office.Interop.Word. When I opened context menu add reference - I haven't find it there. What should I do?
MS Visual Studio 2012, Windows 7.
Maybe somebody can give me more newer instructions how to program for MS Word?
You did not install the Primary Interop Assemblies when you installed word, that is why Microsoft.Office.* is missing.
Follow these instructions on how to install the assemblies.
To install the PIAs when you install Office
Ensure that you have a version of the .NET Framework that is no older than 2.0.
Install Microsoft Office and make sure that the .NET Programmability Support feature is selected for the applications you
want to extend (this feature is included in the default installation).
To install the PIAs by using the redistributable package
Ensure that you have a version of the .NET Framework that is no older than 2.0.
Download the PIAs for Microsoft Office 2010 from the following page on the Microsoft website: Microsoft Office 2010: Primary Interop Assemblies Redistributable.
Install the PIAs by following the instructions on the download page.
Assemblies > Extensions
and select both the extensions and just click OK and you are done
You have to make sure that word is installed as well. The interop libraries are installed when word is installed. If you cannot find them in the reference, but have word installed, then you can download and find them here for 2010, or here for 2007
Related
I have installed TXTextControl .NET 15.1 with a valid license key on a brand-new Windows Server 2016, and I have installed Visual Studio Build Tools 2017 including .NET 4.6.2 and .NET 4.7.2.
When I build my C# project (targeting .NET 4.6.2), I get the following error:
(CompileLicxFiles target) ->
licenses.licx(1): error LC0004: Exception occurred creating type 'TXTextControl.ServerTextControl, TXTextControl, Version=15.1.800.500, Culture=neutral, PublicKeyToken=6b83fe9a75cfb638' System.DllNotFoundException: The TX Text Control kernel DLL file could not be found.
The error The TX Text Control kernel DLL file could not be found hinted at something missing in the GAC, which I then proceeded to check out.
Running the gacutil.exe that came with .NET 4.7.2 indicated that the necessary registrations for
txkernel.dll
txic.dll
txtools.dll
were not there.
I then went on and installed them manually, both the x86 and AMD64 versions, from their respective locations:
C:\Program Files\The Imaging Source Europe GmbH\TX Text Control 15.1.NET\BrowserBin\txkernel.dll
C:\Program Files\The Imaging Source Europe GmbH\TX Text Control 15.1.NET\BrowserBin64\txkernel.dll
etc.
But it still didn't work!
I then contacted support, but their reply was that my license was no longer valid for support, so they basically refused to answer any questions about the product.
After a while I then got the supporter to say that the company never test OLD versions of TXTextControl on NEW versions of Windows, so my best bet would be to purchase a new license.
Since the license is pretty expensive, and our (PERPETUAL!) license is perfectly valid for running the product, I am determined to find a solution to this issue.
Can anyone help me?
After some struggling, I found the solution: Install .NET 3.5 BEFORE installing TXTextControl .NET.
My hypothesis is that the TXTextControl installer fails to check the exit codes, when running gacutil.exe, so it doesn't detect that the registrations have failed.
This means that the recipe for solving this problem (which I post here for Bingle to pick up), is to:
wipe any GAC registrations you may have made in an attempt to manually install the TXTextControl DLLs
uninstall TXTextControl .NET
go to Server Manager and "Add Roles and Features", and then on the "Features" pane, you put a checkmark next to ".NET Framework 3.5 Features" (which causes a single checkmark to be in ".NET Framework 3.5 (includes .NET 2.0 and 3.0)")
reinstall TXTextControl .NET
After this was done, I could build my code!
From having similar sounding issues with the ASP.Net version, make sure that you also have Visual C++ Redistributable Packages for Visual Studio 2013 installed as since v25 this has been required and for any machines that don't already have that installed then the ASP.Net version throws similar errors about txic.dll.
I always struggle with finding references for documented classes. Take the HardwareIdentification class for example. Ik can find the documentation just fine here. In the documentation it says the class is in the System.Windows.Profile library. When however I open the 'Add reference' box this library is not found in either 'Assemblies.Framwork' or 'Assemblies.Extensions'. My search on Google results in find nothing. The NuGet package manager doesn't find this assembly either. So where is it? It's not in the GAC too.
The docs page mentions the Device Families and luckily provides the Windows SDK version that goes with that:
Windows Desktop Extension SDK (introduced v10.0.10240.0)
Windows Mobile Extension SDK (introduced v10.0.10240.0)
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
It also mentions that these Assemblies are for the WindowsRT / UWP development, it's likely these won't work elsewhere.
You can download the latest Windows SDK here:
https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
The default installation location is:
C:\Program Files (x86)\Microsoft SDKs
C:\Program Files\Microsoft SDKs
If you're using Visual Studio 2017, you may need to enable the correct workloads for the SDK elements to be installed, my workload, for example, doesn't contain UWP.
After deploying a VSTO Excel Add-In I am unable to read the app.config file.
My question is identical to this one:
VSTO Debug version fine, Installed version doesn't read app.config
Except, when I change the registry entry to use the file:/// as suggested in the post I get the following error:
The common language runtime could not be loaded by file:///C:\Program Files (x86)\company\product\addin.vsto|vstolocal. Contact your administrator for further assistance.
Without using file:/// the Add-In loads fine but doesn't read the configuration file.
I am using the following software:
Excel 2010 (installed - 32bit)
VSTO 2010 (10.0.60724 - 64bit)
Windows 7 (64-bit)
.NET (4.6.00081)
The link here says that based on my software I needed to install the 64bit of VSTO:
https://msdn.microsoft.com/en-us/library/bb608603.aspx?f=255&MSPPError=-2147217396
I tried to install .NET 4.0 and .NET 4.5 but as 4.6 is installed it won't continue. 4.6 is required by the add-in.
Is there something I am missing that is required to get this to work?
I managed to resolve this. The problem was that InstallShield does not contain a prerequisite of .NET 4.6.1 yet and so the developer had selected .NET 4.6 instead, however when the Add-In loads it looks for the exact version of .NET it requires which was not part of the installation.
To resolve, I removed .NET 4.6 and installed 4.6.1 manually.
I'm developing a C# project using Microsoft Word 2007. I add to my project a reference to the Word component. After compiling I can't find Interop dll in the bin. Where can I find Interop dll? I need to copy it.
In the Word Component, expand your project references, find the Interop dll, highlight it, and in the properties window enable Copy Local. After compiling again, you should now see the dll in your output directory.
In a normal configuration, Office has installed the dll (PIA = Primary Interop Assembly) in the GAC. So there's no need for you to distribute it with your project.
With Office 2007 there's always the caveat that the PIAs are not installed by default, so the user's machine might not have them in the GAC. For this reason, Microsoft has provided a redistributable as a download. Your installation can check for the presence of the PIA(s) used in your project and install them (same as you would the .NET Framework).
It's possible to create your own IA using tlbimp.exe (https://msdn.microsoft.com/en-us/library/tw4zwhbe(v=vs.110).aspx) and there are circumstances when you might want to do so. In this case, you would distribute the dll with your project.
Hans mentions the "Embed interop types" option for more recent versions of the .NET Framework. This can be useful, but thorough testing is necessary as this option sometimes gives "unexpected results" (embeds the wrong or incomplete information from the PIA).
I have referenced "Microsoft.Office.Interop.Excel" library in my application to generate excel with embed interop type set to "True". Build happens fine in Dev machine which has excel installed. My doubt is whether the same application builds fine in the Build machine which does not have excel installed.
Got to know that these COM libraries are installed in GAC assembly. Does this library come by default with .net framework or comes with installation of MS-Office excel?
I'm building my application in .net framework 4.0.
Please clarify.
No, the office COM libraries are not installed by default in the GAC. They are not part of the .Net framework. Office, (or at least all the appropriate dlls) have to exist on the target machine.
Edit:
see MS OFFICE C#: Primary Interop Assemblies
To Answer your qunestions
My doubt is whether the same application builds fine in the Build
machine which does not have excel installed?
Yes it will build fine but if you have implemented any Excel related functions it will not work in your build machine. Interop Assemblies are a way to work with office application from your managed code, So without having Office installed Interop is useless.
Does this library come by default with .net framework or comes with
installation of MS-Office excel?
The PIAs(Primary Interop Assembly) are installed automatically when you install Office on the development computer