com-interop

Printer properties silverlight com-interop and out of browser

天涯浪子 提交于 2019-12-06 15:54:01
I need to access a printer to know if is active and have paper. I'm using silverlight 4 out of box with elevated trust. At this point I have: string cFileName = "temp.txt"; string cAction = "print"; using (dynamic fso = AutomationFactory.CreateObject(@"Scripting.FileSystemObject")) { dynamic file = fso.CreateTextFile(cFileName, true); file.WriteLine("First line text"); file.WriteLine("second line text"); file.Close(); } //Print dynamic shell = AutomationFactory.CreateObject("Shell.Application"); shell.ShellExecute(cFileName, "", "", cAction, 1); I'm using a temp file txt to creat my print page

Exception handling: how granular would you go when it comes to argument validation?

旧街凉风 提交于 2019-12-06 12:20:20
问题 I'm coding a simple little class with a single method send an email. My goal is to implement it in a legacy Visual Basic 6 project, exposing it as a COM object via the COM Interop facility. There's a detail I'm finding difficult to resolve, that being how granular should I be at validating parameters. On that light, a thing I'm really not happy about, and which is not a detail at all, is the way I'm actually handling exceptions: public class MyMailerClass { #region Creation public void

Load a .NET assembly from a COM ProgID without creating a COM object

我只是一个虾纸丫 提交于 2019-12-06 12:08:52
问题 A bit of an odd question and probably backwards from what most people want to do, but I'm trying to work around a legacy COM issue. I have two components, both of which are actually .NET assemblies, but for historical reasons one is loading the other as a COM object (the assembly is registered for COM Interop). It's a plug-in architecture where the plug-in is identified by its COM ProgID, so that's the only piece of information I get to load the plug-in assembly. One technique I've tried is:

VB6 event passing bool argument that's always 'true' in C#

冷暖自知 提交于 2019-12-06 10:50:59
问题 My problem is simple, I have an event declared in a VB6 library that passes out a boolean argument: Public Event WriteComplete(ByVal aCommsOk As Boolean, ByVal aBadPIN As Boolean) I have hooked my c# code up to this event many times but bizarrely my testing department and a couple of other ppl have noticed that although VB6 raises this event with aBadPIN set to false, the c# event handler receives it as true. It is not consistent so it's one of 'those' problems but I'm not finding anything on

Is it possible to forward delegate through COM interop?

a 夏天 提交于 2019-12-06 09:41:38
问题 I have a class: public class A { public delegate void SetTextDel(string value); public void Test() { SetTextDel setText = someInterface.SetText; icom.Set(setText); } } [ComVisible(true), Guid("81C99F84-AA95-41A5-868E-62FAC8FAC263"), InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface Icom { void Set(Delegate del); } [ComVisible(true)] [Guid("6DF6B926-8EB1-4333-827F-DD814B868097")] [ClassInterface(ClassInterfaceType.None)] [ComDefaultInterface(typeof(Icom))] public class B : Icom

Excel Interop: Range.FormatConditions.Add throws MissingMethodException

为君一笑 提交于 2019-12-06 09:23:21
I am writing an application which uses the Microsoft.Office.Interop.Excel assembly to export/import data from Excel spreadsheets. Everything was going fine (except for 1 based indexing and all those optional parameters!), until I tried to use conditional formatting. When I call Range.FormatConditions.Add I get a MissingMethodException telling me that no such method exists. This happens in both Vista and XP. Here's an example of the code that generates the exception: //1. Add a reference to Microsoft.Office.Interop.Excel (version 11.0.0.0) //2. Compile and run the following code: using

How to import a tlb and a namespace in c++ at runtime when some condition meets?

China☆狼群 提交于 2019-12-06 08:59:09
Generally we import a tlb file at the starting of the program like #include < stdio.h > #import " sql.tlb " But i need to import a tlb file when certain condition meets in the middle of the program how can i do this. to load dll there is LoadLibrary() but to load tlb can i use LoadLibrary() . Since tlb is generated by using .dll? You can load a type library at runtime using LoadTypeLib . ITypeLib *ptlib; LoadTypeLib("sql.tlb", &ptlib); What you do then with ptlib is kind of up in the air as you don't really say what you are trying to do with it. ptlib is an object supporting the ITypeLib

How exactly do I config DCOM to load my DLL into a separate process?

∥☆過路亽.° 提交于 2019-12-06 08:47:50
问题 I'm trying to force an existing native C++ ATL in-proc COM server into a separate process. I hope DCOM can do this for me without changing the COM server. I started with a usual registry setup - I have a HKCR\CLSID{classId} entry and an InProcServer32 key there specifying the path to the .dll file. I generated an application id (GUID) and added it here and there. Specifically I added a string value "AppId" under HKCR\CLSID{classId} equal to the application id. I also added a HKCR\AppId

Excel interop libraries incompatible with ASP.NET?

孤街醉人 提交于 2019-12-06 06:19:09
I have a simple web application which uses the Excel Interop libraries to read and insert into an Excel spreadsheet. I'm taking my due diligence to ensure that I don't use two dots and to ensure that all COM object references are released by using Marshal.ReleaseComObject() and GC.Collect() , but there is still an EXCEL.EXE process running on my server. I've created a Windows Forms application that uses the same object releasing process as in my ASP.NET app, and it ends the process successfully. Is there something involved with using the Interop libraries with ASP.NET that I've overlooked?

“Access to the Registry Key Denied” when building a .NET DLL for COM Interop

寵の児 提交于 2019-12-06 06:09:58
问题 Objective : build a C# DLL with COM interop to be called by Delphi on another environment. Problem : Windows is blocking my build, saying that I don't have privileges to edit the registry. Context: I'm using Windows 8, Visual Studio 2012, UAC is turned off. I'm using RGiesecke's DllExport to annotate with [DllExport] the methods that I want to export as an Dll. I'm using [ComVisible(true)] as suggested here. My solution platform target is x86 I edited my solution's build propertires and