com-interop

Anatomy of a “Memory Leak”

巧了我就是萌 提交于 2019-12-28 01:38:20
问题 In .NET perspective: What is a memory leak? How can you determine whether your application leaks? What are the effects? How can you prevent a memory leak? If your application has memory leak, does it go away when the process exits or is killed? Or do memory leaks in your application affect other processes on the system even after process completion? And what about unmanaged code accessed via COM Interop and/or P/Invoke? 回答1: The best explanation I've seen is in Chapter 7 of the free

Excel: Values from Ranges With Multiple Areas

♀尐吖头ヾ 提交于 2019-12-25 07:50:05
问题 I would like to get the values of a non contiguous, multi area range in excel using C#. I have seen another SO question that says I can do something like this: obj[,] data = sheet.get_Range("B4:K4,B5:K5").get_Value(); However, when I examine the result I see that I only get the data from the first area: "B4:K4" . Testing further, I found that if I request the data in the following way: obj[,] data = sheet.get_Range( "B4:K4","B5:K5").get_Value(); I get the data for both areas... So, my

Create Pervasive Database using Distributed Tuning Objects (DTO)

家住魔仙堡 提交于 2019-12-25 06:49:08
问题 I am writing an application in C# (.NET 4.0) which has to integrate with another, much older application. Part of the requirement is to integrate with a much older program that uses Pervasive PSQL Version 9. I asked this question about accessing the database without having to install an ODBC DSN. Part of the answer (thanks very much) is that I need to create a database using DTO. I've used COM interop to access the dto2.dll COM library, and have read the samples, but I am having problems

Access Violation inside inetinfo.exe when passing byte array through IMSAdminBase from a .NET app compiled to AnyCPU

余生长醉 提交于 2019-12-25 06:33:21
问题 Consider the following piece of .NET code: byte[] hash = { 0x60, 0x2B, 0x45, 0x9D, 0xA0, 0x6D, 0xD5, 0x02, 0x43, 0x86, 0xC1, 0xBA, 0x6B, 0x14, 0x37, 0x88, 0x63, 0x08, 0x39, 0xA0 }; using (var adminBase = TemporaryComObject.Wrap(new MSAdminBase_W())) using (var ptrHash = new AllocHGlobal(hash)) { using (var siteKey = new AdminBaseKey(adminBase.Com, adminBase.Com.OpenKey(METADATA_MASTER_ROOT_HANDLE, "/LM/W3SVC/1", METADATA_PERMISSION_READ | METADATA_PERMISSION_WRITE, 10000))) { var record = new

Automation error with interop

大憨熊 提交于 2019-12-25 02:59:56
问题 I have recently had to rebuild a C# interop created for calling from VB6. I have registered it with regasm (using codebase switch) and added the tlb as a reference to the VB6 project but when I attempt to call it I get the following automation error: -2146232832 (0x80131600) If I register the existing interop dll in exactly the same way and add to my project, it works fine. The only differences I can think of are that the project has since been upgraded from VS8 to VS9 (same .net version

What to pass as the first parameter to IActiveScriptProfilerControl.StartProfiling?

心不动则不痛 提交于 2019-12-25 02:56:03
问题 Trying to use IActiveScriptProfilerControl::StartProfiling from my C# code, I've created this interface definition: [ComImport] [Guid(@"784b5ff0-69b0-47d1-a7dc-2518f4230e90")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IActiveScriptProfilerControl { void StartProfiling( ref Guid clsidProfilerObject, ProfilerEventMask eventMask, uint dwContext); // ... } Which I believe is correctly translated to .NET. The original first parameter is defined as [in] REFCLSID

DLL for VBA.Collection

旧时模样 提交于 2019-12-25 02:37:12
问题 I need to use a VBA.Collection class and I need to register a COM component in order to do that. I found msvbvm60.dll file on my computer and successfully registered it in my system. I am creating an instance of a class VBA.Collection, but I get an exception in that line of code: VBA.Collection collection = new VBA.Collection(); The exception has the following description: System.Runtime.InteropServices.COMException was unhandled HResult=-2147221164 Message=Retrieving the COM class factory

“Invalid Callee” while using MLapp in C#

怎甘沉沦 提交于 2019-12-25 02:25:14
问题 I'm having a strange issue while using the MLApp.GetWorkspaceData function. I noticed that this functions works properly when I do the following: matlab = new MLApp.MLAppClass(); object myObject; matlab.GetWorkspaceData("myVariable", "base", out myObject); But if I then try to use the same object as an output I get an "Invalid Callee" exception. In addition this also gives the same error: matlab = new MLApp.MLAppClass(); object myObject = new object(); matlab.GetWorkspaceData("myVariable",

Can a SilverLight component instantiate a registration-free COM-visible .NET object

↘锁芯ラ 提交于 2019-12-25 01:44:31
问题 We are trying to load in SilverLight 5.0 component running in IE a COM-visible .NET object registration-free using the activation context API. http://msdn.microsoft.com/en-us/library/ms973913.aspx The SilverLight component is runnning as a trusted application in the browser as described in http://msdn.microsoft.com/en-us/library/gg192793(v=vs.95).aspx. The object can be loaded in a stand-alone test application using the activation context API so the manifest is properly formed. In SiverLight

UWP sideload app that use Microsoft.Office.Interop.Outlook COM

こ雲淡風輕ζ 提交于 2019-12-24 23:52:34
问题 Hello Im updating a UWP app that we use in ouroffice. Before when we use it to send email it uses the Windows.ApplicationModel.Email.EmailMessage however this i really limited. So i would like to use Microsoft.Office.Interop.Outlook instead to create the email directly with outlook My test code looks like this. try { List<string> lstAllRecipients = new List<string>(); //Below is hardcoded - can be replaced with db data lstAllRecipients.Add("info@test.com"); //lstAllRecipients.Add("chandan