interop

Using SetWindowPos in C# to move windows around

I have the code below: namespace WindowMover { using System.Windows.Forms; static class Logic { [DllImport("user32.dll", EntryPoint = "SetWindowPos")] public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags); public static void Move() ...

Outlook Redemption : How to Access RDORules or rules from outlook in c#

I am using Outlook redemption to access all rules from outlook. How could we get RDORules using Outlook Redemption in c# ? I have tried accessing this using below code Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook._NameSpace ns = app.GetNamespace("...

Hosting a .net assembly for COM interop with long lifetime?

I have a component (an assembly built in .net) that i need to access on (almost) every request to two different websites. One website is written in classic asp and the other one in asp.net mvc. At the moment i reference the assembly in the asp.net solution and call it like i would any .net assembly. On the classic asp website, i call it...

How do I implement the dispose pattern in c# when wrapping an Interop COM Object?

My class contains an object from Interop and calls a method on it which causes it to alloc stuff. It also exposes a method to free that stuff, so I expect I should call this in Dispose(): class MyClass : IDisposable { private DllName.ComClassName comInstance; void SomeMethod() { comInstance = new DllName.ComClassNam...

How to marshal a variable sized array of structs? C# and C++ interop help.

I have the following C++ structs struct InnerStruct { int A; int B; }; struct OuterStruct { int numberStructs; InnerStruct* innerStructs; }; And a C++ function OuterStruct getStructs(); How can I marshal this to C#? Where the C# definitions is struct OuterStruct { InnerStruct[] innerStructs; }; ...

Invalid Variant crash

I have a situation where I've wrapped a Native C++ DLL with C++/CLI for eventual use in C#. There are a few callback functions that are causing some issues at run time. Particularly, I get the following exception: An unhandled exception of type 'System.Runtime.InteropServices.InvalidOleVariantTypeException' occurred in ToadWra...

How do I set the color of an individual point in an Excel scatterplot using .NET?

I am trying to set the color of individual points in an Excel scatterplot through C#, but can't get it to work. Here is the code I am currently using. Note that the MarkerStyle and MarkerSize part of the code works - so my issue is really about color. I suspect I am missing a cast somewhere. var point = (Excel.Point)series.Points(index)...

Names in the interop assembly have wrong capitalization

I have a VC++ COM component with a type library. The type library of this component declares an interface and a co-class: [ object, uuid( ActualUuidHere), dual, nonextensible, oleautomation, hidden, helpstring( ActualHelpStringHere ) ] interface IWorkflow : IDispatch { //irrelevant properties here } ...

Is there no way to obtain sender's emailId from outlook calender data using Microsoft.Office.Interop , c#.net

I want to get the sender's emailId. I am able to read all the data of calender by the below code but not the sender's emailId. using Microsoft.Office.Interop.Outlook; Microsoft.Office.Interop.Outlook.Application outlook = new Application(); Microsoft.Office.Interop.Outlook.NameSpace oNS = outlook.GetNamespace("MAPI"); oNS.Logon(Missin...

WinForms Interop, Drag & Drop from WinForms -> WPF

Hello all! I'm trying to drag data from the Winforms portion of my application on a WPF controls that's contained inside an "ElementHost". And it crashes when I try doing so. Trying the same thing but from Winforms to Winforms works fine. (See example code below) I need help on making this work... have any clues what I'm doing wrong? ...

adding adorners to legacy textboxes

Whats the best way to add an adornment layer to legacy controls, or in other words you know jetbrains refactoring tools, how do they draw the squiggly lines under incorrect text? Also on another note can one draw said adorments on controls not under the direct reference of the application, ie using a handle? If you have insights, or jus...

what are some cross-language libraries for people who know other languages (similar to phpjs)

PHPJS attempts to port php functions over to javascript. http://phpjs.org/ Rationale: people who know php's functions really well can write javascript and just carry over what they know from php into the javascript world Question: I would like to know if there are other language libraries where someone ported concepts from language X...

How to send a message from one instance of a managed app to another?

I've got a WinForms app, where if there is already an instance running & the user tries to spin up another one, I stop it by checking against a Mutex before calling Application.Run(). That part works just fine. What I would like to do is pass a message from the new instance of the app (along with a piece of data in string form) to the ...

How to cast a control to IOleObject

I want to invoke GetClientSite on a .net control. For this purpose I am trying to cast a control (in example Windows.Forms.Form) to IOleObject which returns null. What should I do to get IOleObject? using System; using System.Runtime.InteropServices; using System.Security; using System.Windows.Forms; namespace Test001 { public cla...

replace cell values within excel using excel.interop

I want to scan an excel sheet, and replace any occurrences of social security numbers with zeros... I would like to do this using Excel.Interop if at all possible, but I'm open to anything at this point... here's some of my code... I'm banging my head on the desk for the past few months... // Get range and convert it to a string varia...

vba Extentiblity, com addin guidance?

Does anyone know of good reference material for creating a com addin for the VBA Editor enviroment, i know its exactly the same as writing a com addin for common enviroments using the addin model provided by microsoft using the IDTExtensibility2 interface. just registering the com registry keys to a different location, Where is that loca...

PInvoke error when marshalling struct with a string in it

I have a C++ struct struct UnmanagedStruct { char* s; // Other members }; and a C# struct struct ManagedStruct { [MarshalAs(UnmanagedType.LPStr)] string s; // Other members } the C++ library exposes extern "C" UnmanagedStruct __declspec(dllexport) foo( char* input ); And it is imported like [DllImport("SomeDLL.dl...

Can DLL exports be automatically discovered and interop code generated?

C#: I have a standard win32 DLL from a vendor that talks to a hardware device. Is there any utility to automatically generate my interop code by discovering the exports in the DLL? This is not a COM dll. There is no def file, all I have is the DLL. ...

How should a .NET developer learn C++ ?

Ok. Here is a summary of my experience/knowledge/etc listed: I have only worked with 2 languages: C# and F# I am only familiar with programming in a managed environment I have a solid understanding of C# syntax I have a solid understanding of C#'s type system I have never looked at a line of C++ code I do not know C++'s type system ...

How to check if .net interoperability for excel is installed

Hi, I am using .net Primary Interoperability Assembly for Excel in my code. But, the application can be run on machine which doesn't have .net PIA for Excel installed. I want to give an error message if it is not installed Even though I am checking in GAC, to see if PIA is installed and only if it is present I am using Microsoft.Office...