interop

Why is it possible to create a new instance of a COM interface?

☆樱花仙子☆ 提交于 2019-12-19 16:13:07
问题 I don't have very much background regarding COM nor coclasses, so I don't quite understand why I can use the new operator with an interface. From a language/framework-agnostic view, it's confusing why this compiles and runs correctly: using Microsoft.Office.Interop.Excel; public class ExcelProgram { static void Main(string[] args) { Application excel = new Application(); } } Inspecting Application in Visual Studio 2010 shows me: using System.Runtime.InteropServices; namespace Microsoft.Office

Need signature after SAML token in client request

前提是你 提交于 2019-12-19 10:23:28
问题 I have a serialized SOAP request message with a SAML token holder-of-key that works against a vendor service. I want to create a demonstration program in C# to produce a similar request. To do this, I want to write a client that creates its own SAML token. I've got a SAML2 token created successfully from a self signed cert and I am able to associate it to the request using the ChannelFactoryOperations.CreateChannelWithIssuedToken approach (.Net 4.0). Everything is working great but I can't

Why does excel remain open? [duplicate]

陌路散爱 提交于 2019-12-19 10:17:21
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to properly clean up Excel interop objects in C# I've this function that I use to calculate the linear trend of some data: private string Trend(object conocido_y, object conocido_x, object nueva_matriz_x) { string result = String.Empty; try { Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); result = ((Array)xlApp.WorksheetFunction.Trend(conocido_y, conocido

How can I create a header in a table for each new page with Word interop?

落爺英雄遲暮 提交于 2019-12-19 09:23:31
问题 I am trying to create a table with a header. I want this header to be repeated for each new page that the table takes. How can I do this in C# with Word 2007 Interop? 回答1: Microsoft.Office.Interop.Word.Table table; /* ... */ table.Rows[1].HeadingFormat = -1; 回答2: This is what word for me, Looping through each table at the end foreach (Table item in doc.Tables) { item.Rows[1].HeadingFormat = -1; item.ApplyStyleHeadingRows = true; } and setting a style on each table with the property set to

How do I preserve COM binary compatibility for a .NET Assembly when properties are added?

≯℡__Kan透↙ 提交于 2019-12-19 07:49:07
问题 We have developed a .NET Assembly that stores language translation information and it needs to be consumed by a VB6 application. We would like to be able to change the translation information without having to recompile the application. The translation is provided by a two-file partial class called LanguageServices. One file is non-changing library methods, the other is all auto generated properties from a resx file and the regx is generated from a database of language translation information

PCWSTR vs LPWSTR

怎甘沉沦 提交于 2019-12-19 06:57:15
问题 It is my understanding (and please correct me if I'm wrong) that the only difference between them is whether the string might be modified by the called function. (PCWSTR , LPWSTR) I am now trying to pass a string from C# to a function expecting a PCWSTR , but all I can find is [MarshalAs(UnmanagedType.LPWStr)] . Am I correct that that is fine? (Yes, it works . That, though, is not a proof that it's fine. Some things work but then cause memory leaks etc.) 回答1: PCWSTR is a time anachronism,

Cannot implicitly convert type 'object' to 'Microsoft.Office.Interop.Excel.Worksheet'. An explicit conversion exists (are you missing a cast?)

 ̄綄美尐妖づ 提交于 2019-12-19 06:05:32
问题 Here I'm opening excel and writing to excel sheet. I'm changing my windows application to asp website and seen this error. I have added all the references and libraries. Don't know what I am missing here. Getting error as mentioned below. Please help me. Excel.Application excel = new Excel.Application(); excel.Visible = false; // to hide the processing Excel.Workbook wb = excel.Workbooks.Add(); Excel.Worksheet sh = wb.Sheets.Add(); // Error at wb sh.Name = "Links"; for (int i = 1; i < list

Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80080005

妖精的绣舞 提交于 2019-12-19 05:38:30
问题 What is the troubleshooting process for the "Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80080005" errors in .Net? To clarify: I am getting this at runtime, on my XP machine, with client being .net code running under admin account. {XXXX} refers to one of our in-house COM components. From what I understand, 0x80080005 refers to "permission denied", but where do I go to check/change the permissions? Or am I completely wrong here, and the

Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80080005

試著忘記壹切 提交于 2019-12-19 05:38:28
问题 What is the troubleshooting process for the "Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80080005" errors in .Net? To clarify: I am getting this at runtime, on my XP machine, with client being .net code running under admin account. {XXXX} refers to one of our in-house COM components. From what I understand, 0x80080005 refers to "permission denied", but where do I go to check/change the permissions? Or am I completely wrong here, and the

How to best convert VARIANT_BOOL to C++ bool?

痴心易碎 提交于 2019-12-19 05:05:35
问题 When using COM boolean values are to be passed as VARIANT_BOOL which is declared in wtypes.h as short . There are also predefined values for true and false : #define VARIANT_TRUE ((VARIANT_BOOL)-1) #define VARIANT_FALSE ((VARIANT_BOOL)0) Which is the best way to convert from VARIANT_BOOL to C++ bool type? Obvious variants are: compare with VARIANT_FALSE simply cast to bool Other ways can be easily invented. Which is the best way to do this - most readable, most standart-compliant, least prone