I am developing a plug-in (ribbon) for Excel in Visual Studio 2013 using C# and VSTO.
So far, so good. Now, I want to create an installer. I am using InstallShield Limited Edition for Visual Studio. I followed the instructions given here http://msdn.microsoft.com/en-us/library/cc442767.aspx (Per-user installation, application-level add-in).
The compilation and setup work out without any problems. However, when I open Excel, I get this warning:
Name:
From: file:///C:/Program Files (x86)/DCDB/ExcelInterface.vsto
************** Exception Text **************
Microsoft.VisualStudio.Tools.Applications.Deployment.InstallAddInFailedException: The customization cannot be run because
the solution ID in the document does not match the customization. Contact your administrator for further assistance.
at Microsoft.VisualStudio.Tools.Office.Runtime.OfficeAddInDeploymentManager.RefreshCustomization(Customization cust,
AddIManifestsDownloadedArgs args)
at
Microsoft.VisualStudio.Tools.Office.Runtime.OfficeAddInDeploymentManager.OnAddInManifestsDownloaded(AddInManifestsDownloade
dArgs args)
at
Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.RaiseOnAddInManifestsDownloadedEvent(I
ClickOnceAddInInstaller addInInstaller, Uri deploymentManifestUri, AddInInstallationStatus addinSolutionState, String
productName, String deploymentManifestXml, String applicationManifestXml, String hostManifestXml, String logFilePath,
String version, Uri supportUri)
at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()
at Microsoft.VisualStudio.Tools.Office.Runtime.SolutionInstaller.<>c__DisplayClass7. <Install>b__0()
I have been searching on the net and there is no answer, only questions.
I cannot understand the nature of the error message. Any ideas?
For anyone out there that encounters this problem in the future. I found that the problem is not a real problem. I was able to close the error message and open the Excel File directly and it worked fine.
I did add the solution ID to the Manifest value after the the filename: file:///[INSTALLDIR]ExcelWorkbook.vsto|SOLUTIONID|vstolocal.
But I'm not sure that actually made a difference. I still got the same error.
I added a shortcut to the ExcelWorkbook.xlsx to the end users desktop which helped to ensure that the end user will open the Workbook directly, and not Excel.
Related
I am getting errors in event viewer every time my application runs this line:
Redemption.RDOSession rSession = RedemptionLoader.new_RDOSession();
event viewer error:
faulting application name: (my.exe)
exception code: 0xc0000005
faulting module path: C:\Program Files\Common Files\Microsoft Shared\Office16\mso20win32client.dll
The oddest part is that it proceeds to create the session and makes it to the end of my code if I let it, successfully looking up an email in Outlook. This is in production and has worked for years, but for some months now it has been racking up the same error in Event Viewer. End users don't notice, but IT is seeing thousands of errors now which makes it hard for them to know when other problems might be showing up.
I reproduced this on the first try with:
Windows 10 Home, OS build 19044.1706, Windows Feature Experience Pack 120.2212.4170.0
Outlook: Microsoft® Outlook® for Microsoft 365 MSO (Version 2205 Build 16.0.15225.20172) 64-bit
I added logging in my CS code to make sure this caused the error. The error occurs if set ignoreoutlook to "e", and not if I set it to "d":
Microsoft.Office.Interop.Outlook.Application oApp = (Application)Marshal.GetActiveObject("Outlook.Application");
if (ignoreoutlook.Equals("d")) return;
Redemption.RDOSession rSession = RedemptionLoader.new_RDOSession(); // new Redemption.RDOSession();
if (ignoreoutlook.Equals("e")) return;
As for:
C:\ProgramFiles\Common Files\Microsoft Shared\Office16\mso20win32client.dll
it doesn't exist. There is a dll of that name in both:
C:\Program Files\Microsoft Office\root\vfs\ProgramFilesCommonX86\Microsoft Shared\OFFICE16
C:\Program Files\Microsoft Office\root\vfs\ProgramFilesCommonX64\Microsoft Shared\OFFICE16
If Redemption wants to use that dll, how is it working without it?
Is there a way to configure Redemption to skip that dll and move on to whatever else it must be doing to get it to work after that error?
There are quite a few things going on once the MAPI system (when Redemption loads it and calls MAPIInitialize) initializes common Office runtime, which has a bunch of its own problems, since it loads telemetry and licensing. Some of that functionlity only works when running inside the (virtualized) Office app environment (it patches a few Win API functions etc.)
Check if you see the same problem in MFCMAPI if you log to a profile (to ensure the MAPI system is loaded). If you do, that means the problem is in the MAPI system and you can work with MS support. If not, something is specific to your app.
One thing to keep in mind is that your app must embed a manifest and advertise its support for Windows 10. Otherwise common Office run-time tries to patch wrong Win API functions.
lately I have encountered a following problem. Azure Function that is run in Visual Studio always throws an exception:
System.IO.IOException HResult=0x80131620 Message=Error loading
native library
"C:\Users\\AppData\Local\AzureFunctionsTools\Releases\2.16.0\cli\grpc_csharp_ext.x86.dll"
Source=Grpc.Core StackTrace: at
Grpc.Core.Internal.UnmanagedLibrary..ctor(String[]
libraryPathAlternatives) at
Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary() at
Grpc.Core.Internal.NativeExtension.LoadNativeMethods() at
Grpc.Core.Internal.NativeExtension..ctor() at
Grpc.Core.Internal.NativeExtension.Get() at
Grpc.Core.GrpcEnvironment.GrpcNativeInit() at
Grpc.Core.GrpcEnvironment..ctor() at
Grpc.Core.GrpcEnvironment.AddRef() at
Grpc.Core.Server..ctor(IEnumerable`1 options) at
Microsoft.Azure.WebJobs.Script.Grpc.GrpcServer..ctor(FunctionRpcBase
serviceImpl) in
C:\azure-webjobs-sdk-script\src\WebJobs.Script.Grpc\Server\GrpcServer.cs:line
24
The file that is supposedly missing is at its place of course. I've tried to reinstall Azure Function Tools and Visual Studio and nothing helped. Any ideas?
Thanks in advance.
EDIT1:
The problem seems to be caused by non-english characters in the path to the library. I've just created another account without them and suddenly everything started to work.
from the point that the root cause of error is because of the non-english characters in the path to the library, you can consider to rename path of your user profile.
To do so, here is the steps
Log out and login with another Administrator user to your PC
open command prompt by CTRL + R then type cmd
type wmic useraccount get name, sid and get SID of your profile
type regedit under start menu, right click on it and select Run as Administrator
Go under Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\YOUR_SID_HERE
Double Click on ProfileImagePath and change the value data according to your need (you can close Registry Editor)
go under USER PROFILES folder (%USERPROFILE%\..\) and change the path of your user profile accordingly
Restart your computer
Description
When launching any Console Application, the code stops running immediately on an AccessViolationException (Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt). More info included in the next section.
Technical Symptoms
The Call Stack only contains external code:
Exception:Thrown: "The message filter indicated that the application is busy. >(Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))" (System.Runtime.InteropServices.COMException)
A System.Runtime.InteropServices.COMException was thrown: "The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))"
Time: 12/10/2015 10:59:55 AM
Thread:vshost.NotifyLoad[15344]
I created a new Console Application, containing only Console.WriteLine("Hello world!");
Running the new Hello world app results in the same exception and an identical
call stack.
Background
I suspect this has nothing to do with the issue, as I will explain, but I feel it is important to answer the obvious question, "what were you doing when the issue happend?" The last change I made was adding an extension to my Selenium Driver to hotkey logout from an application:
public static void logout(this IWebDriver Driver)
{
Driver.FindElement(By.TagName("body")).Click();
new Actions(Driver)
.SendKeys(Keys.Control + Keys.Shift + "x")
.Perform();
}
I also made a change in my App.Config file for one of my projects, but reverting this had no impact either.
Removing this code (the Driver extension and/or the App.Config change) does not resolve this issue. Retrieving a previous check-in does not resolve the issue. I am the only person currently working on this solution.
Discoveries
As mentioned, this is happening for an empty Console Application. Windows Form Applications launch fine. Unit Test Projects launch fine as well.
Research
I've spent hours looking into this. It seems like every similar issue I have looked into is pertinent to debugging only or a .NET version. For me, the issue occurs with a Release as well. Additionally, I have been using .NET 4.5 without any issues or changes on that front. I can't find any articles that seem worth posting, but I might be overlooking something.
Visual Studio Info
Microsoft Visual Studio Ultimate 2013
Version 12.0.30501.00 Update 2
.NET Version 4.6.00081 (just noticed it says 4.5 in my project properties, though)
Running as Administrator
Feedback
When Running from devenv.exe /SafeMode, Visual Studio loaded with:
An exception was encountered while constructing the content of this frame. This information is also logged in "C:\Users\UserName\AppData\Roaming\Microsoft\VisualStudio\12.0\ActivityLog.xml".
Exception details:
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at Microsoft.VisualStudio.Shell.Interop.IVsShell5.LoadPackageWithContext(Guid& packageGuid, Int32 reason, Guid& context)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.GetPackage()
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.ConstructContent()
Additionally, when trying to run, I get an error message of "Error while trying to run project: Invalid Pointer" (again, VS in devenv.exe /SafeMode - see how to run visual studio without plugin and all third party feature if unfamiliar)
Please let me know if I can provide any additional information.
It may be because when you name the project you can't put spaces, I put them and it gave me a AccessViolationException aswell, try using capitals to separate your words, but only use letters and no spaces to be sure.
I also faced this issue with Visual Studio 2010. More interestingly I had several projects in my solution (Console application, WPF application, Windows Forms application) but it was failing only when, I was setting the project which was of type "Console Application" as start up project. Following change finally helped me nail down the issue: Go to project properties of the console application project -> Go to "Debug" tab -> Go to "Enable Debuggers" section in right pane -> Check the "Enable unmanaged code debugging" check box as shown in the snapshot below. Root cause of why it happened is still not known to me. Only thing which I observed as fishy was that there were lot of windows updates which had got installed on my machine the previous night which mostly constituted of office updates and OS updates (More than a dozen KB articles).
When I try to access an Excel spreadsheet using the following code I get a "Library not registered' error when defining the workbook object wrkbuk using C# from Visual Studio 2012 with Office 2007 (ver 12) installed
Microsoft.Office.Interop.Excel.Application excapp = new Microsoft.Office.Interop.Excel.Application();
string bookname = #"C:\Users\Public\Documents\RECRUITMENT & SELECTION\MOVEMENTS\MOVEMENTS\Miscellaneous Documents\VacanciesREAL.xls";
Workbook wrkbuk = excapp.Workbooks.Open(bookname);
Worksheet wrksht = new Worksheet();
The error details are
System.InvalidCastException was unhandled HResult=-2147467262
Message=Unable to cast COM object of type
'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type
'Microsoft.Office.Interop.Excel._Application'. This operation failed
because the QueryInterface call on the COM component for the interface
with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the
following error: Library not registered. (Exception from HRESULT:
0x8002801D (TYPE_E_LIBNOTREGISTERED)). Source=mscorlib
I've created a reference to Microsoft.Office.Interop.Excel.dll in the Office 14 Primary Interop Assembly that comes with VS 2012 and also for the Office 12 version of the dll and neither fixes the problem. I've tried registering the dlls with regasm but this does not help either.
I can create the worksheet wrksht on the following line OK with the Office 14 and Office 12 dlls so the problem seems only affect workbook definition.
Dec 17 2013
Tried reinstalling Office 2007 to no avail but found this solution, which worked. It was at
http://social.msdn.microsoft.com/Forums/vstudio/en-US/d3f92da7-96d3-404b-89d0-d236800ceae5/vs-2012-rc-and-visual-studio-tools-for-office?forum=vsto
Problem is code from multiple versions of Office - I had code from Office 14, possibly coming from VS 2012 install
I suspect that VS 2012 RC has installed the Office 2013 type libraries, and that there are now duplicate versions registered. I got that specific error message
('unable to cast
_Application'....'TYPE_E_LIBNOTREGISTERED')
after a messy uninstall, and then re-installing an older version of Office. I solved it by following the advice of another forum thread here which I'm sadly unable to find...basically I searched the registry for the CLSID in the error message, so, {00020970-0000-0000-C000-000000000046}. Its registry key contained two keys, one of which was called 'TypeLib', which in turn contained another CLSID for the type library. I then searched the registry, starting at the beginning again, for that second CLSID, which led me to the relevant interop type library. It had two entries....8.3 and 8.4, the bigger number corresponding to the later version of Office....which I deleted...and immediately was able to run my program.
I had this exact same problem. Here's how I fixed it:
Go to
HKEY_CLASSES_ROOT\TypeLib\ and search for Office.Interop.Excel.
I found HKEY_CLASSES_ROOT\TypeLib\(guid)\1.8 but its child nodes were empty! I deleted it because Office 15 wasn't installed on that machine, and hey presto - it worked.
Either our VSTO project installer, or our own custom installer must have placed the 1.8 folder there.
I found the solution here:
Error accessing COM components
I had exactly the same issue. If you have installed a new version of Office and for some reason you have to install the older version without removing the new one (For my case I just need to install the Office XP Photo Editor) and this caused the issue.
After spending 3 hours up and down, the best way is to repair the new version of Office and everything was back to normal as it should be.
Hope this info helps provided you have the same or similar scenario.
Something which hasn't been mentioned here but which may be useful is that subkeys of 1.XX can cause issues as well. For example:
Under Computer\HKEY_CLASSES_ROOT\TypeLib{00020813-0000-0000-C000-000000000046} I had the subkey 1.9. This in turn has the subkey 0(or should). Now under this, there were two subkeys - Win32 and Win64. As a result, Visual Studio was unable to resolve the location of Microsoft.Office.Interop.Excel.dll - it was reading two subkeys where it could only read one. Deleting the Win32 subkey fixed my issue completely. Please note that this was done after a complete reinstall of VS 2017 & Office 365 Pro Plus. Hope this helps someone.
I will confirm #stuzor 's answer on two machines I've encountered.
Background:
Windows7 64 bit
Office 2010 (32bit)
Lync 2013
HKEY_CLASSES_ROOT\TypeLib\ , searched for "Office.Interop.Excel". Found the barely existent "1.8" folder. Upon deletion, the function in an old VB.net app began working immediately.
This is an answer if you can not modify or delete the regedit records. I had the same problem, in the company where I work, there are about 30 machines with office 2010 and I could not erase or open records in the regedit. because the client machine was in a domain that would not let me. although I had administrator permissions it did not allow me to delete records in the regedit. I tried to find a solution for 1 month, and I did not find it. so I had to stop using interop and migrate to OpenXml to edit excel templates and ClosedXml to create new excel. This saved my life, because my boss was already pressing me.
Open the project/solution in Visual Studio, and open the console using the Tools > NuGet Package Manager > Package Manager Console command.
and install 2 packages
Install-Package DocumentFormat.OpenXml -Version 2.5.0
Install-Package SpreadsheetLight
pd: OpenXml 2.8 dont work with SpreadsheetLight, better use 2.5.0
add this in the beggining
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using SpreadsheetLight;
in your button or class copy and modify
SaveFileDialog fichero = new SaveFileDialog();
fichero.Filter = "Excel (*.xlsx)|*.xlsx";
if (fichero.ShowDialog() == DialogResult.OK)
{
SLDocument sl = new SLDocument("c:\\bin\\est1.xlsx", "Sheet1");
sl.SetCellValue("E9", "Let's party!!!!111!!!1");
sl.SelectWorksheet("Sheet2");
sl.SetCellValue("C7", "Before anyone calls the popo!");
sl.AddWorksheet("ERTRT");
sl.SetCellValue("B4", "Who let the dogs out?");
sl.SetCellValue("B5", "Woof!");
sl.SaveAs(fichero.FileName);
MessageBox.Show("Report " + fichero.FileName + "!");
}
The registry hack described above fixed the same problem for me. The only difference was I had a 1.9
and a 1.7 entry. I deleted the 1.9 key and my problem was fixed.
Other info:
OS: Windows 10
Visual Studio Professional 2015
C# Windows Form Application
This was on my work laptop. We have Office 2010 installed on each workstation.
Some other things I tried that DID NOT WORK were the following:
Repairing MS OFFICE
Reinstalling MS OFFICE
Downloading Microsoft Office 2010: Primary Interop Assemblies from Microsoft.
I also had several versions of the Microsoft.Office.Interop.Excel.dll on my laptop. Deleting previous versions did not fix the problem.
Glad I went to STACKOVERFLOW.COM because this place ROCKS!!!!!!
We had the same problem.
Our setup is like this :
Office 2010 : Word and Excel
but
Office 2013 : Outlook
We ran the installation program for Office 2010 and choose the repair option.
After that, all the wrong keys in the registry for Word and Excel were deleted and the problem was solved.
Had the same problem... The code that was previously running, started throwing the same exception when a new Application instance was created. To fix this:
Programs and Features, did an order by date installed and could see there were some Microsoft Office 365 updates from the same day the
code had stopped working.
For both Microsoft Office 365 -en-us and Microsoft Office 365 Pro Plus -en-us, right click Change and select Quick Fix
Tried to run my solution and it was working again.
I've created an empty VSTO solution with an Excel 2007 Project. When I build the solution I get this error:
Error 1 An error occurred while
attempting to persist the data. The
message returned is: Could not find
the add-in deployment cache file,
"C:\Program Files\Common
Files\Microsoft
Shared\VSTA\Pipeline\PipelineSegments.store".
Please run AddInStore.Update or
Rebuild (or run AddInUtil.exe on the
command line). Also, ensure your code
has permission to read this file.
I've googled to no avail. Any ideas?
Thanks
Following these steps fixed it:
http://social.msdn.microsoft.com/forums/en-US/vsto/thread/ccccfd29-ce29-4aaa-8d89-56c88a1a8dd4