interop

How to properly clean up Excel interop objects in C#

I'm using the Excel interop in C# (ApplicationClass) and have placed the following code in my finally clause: while (System.Runtime.InteropServices.Marshal.ReleaseComObject(excelSheet) != 0) { } excelSheet = null; GC.Collect(); GC.WaitForPendingFinalizers(); Although, this kind of works the Excel.exe process is still in the background...

Runtime callable wrapper (RCW) scope - process or application domain?

What is the scope of Runtime Callable Wrapper (RCW), when referencing unmanaged COM objects? According to the docs: The runtime creates exactly one RCW for each COM object, regardless of the number of references that exist on that object. If I had to "guess" - this explanation should mean "one per process", but is it really? ...

What is the best standard to use for business document exchange (invoices, POs etc)?

If I need to implement sending and receiving of business documents from system to system (invoices, POs, remittance advice, etc) what standard would you recommend for best interop and why? It could be XML or otherwise. ...

learning c# Excel interop

What are some resources that will help get me up and running quickly with the Excel interop in C#? ...

Using app.config with Interop Controls

I have a .net project (MySolution.Common) that uses the app.config. I am using the project MySolution.Common in an InteropUserControl project called MySolution.InteropCtrl. MySolution.InteropCtrl is embedded into a VB6 project. When the MySolution.InteropCtrl is in the VB6 project, It cannot find the app.config file. Everything in the In...

How can I debug a VB6 project that has a .net interop project which uses an app.config file?

I have a .net interop project that uses an app.config file. When I am running the VB6 project that is using the interop control in Debug mode, the ConfigurationManager cannot find the app.config file. When I make the VB6 project into an exe and rename the app.config file to (VB6 binary name).exe.config, the ConfigurationManager can find ...

WPF ComboBox doesn't stay open when used in a Task Pane

I have a strange bug with WPF Interop and an Excel Addin. I'm using .Net 3.5 SP1. I'm using Add-in Express to create a Custom Task Pane for Excel 2003. Within that taskpane I'm using ElementHost to host a WPF UserControl. The UserControl simply contains a Grid with a TextBox and ComboBox. My problem is that whilst everything displays pr...

ASP.NET session and storing objects that use COM interop

I'm working on an asp.net web site. We have to use com interop to interact with legacy vb6 activex components. The components in many cases rely on receiving a context object (which is itself a vb6 activex component) as a parameter. The context object is fairly costly to construct. Therefore one idea is that a context object is const...

Marshal C++ struct array into C#

I have the following struct in C++: #define MAXCHARS 15 typedef struct { char data[MAXCHARS]; int prob[MAXCHARS]; } LPRData; And a function that I'm p/invoking into to get an array of 3 of these structures: void GetData(LPRData *data); In C++ I would just do something like this: LPRData *Results; Results = (LPRData *)mal...

How can I debug heap errors in a C# class library?

I'm getting a heap corruption error in a C# library module I'm calling through COM in a C++ app. The specific error is: HEAP: Free Heap block 4b61bb8 modified at 4b61be8 after it was freed ... This may be due to a corruption of the heap, and indicates a bug in [app].exe or any of the DLLs it has loaded. The top of the cal...

C# controls in a MFC Application

I am responsible for the User Interface of an application written completely in Visual C++ using MFC and some third-part controls. I would like to use C# (WinForms or even better WPF) to improve the application look&feel. I would like some advices about how to do it. Links, articles, examples... Right now the user interface is isolate...

C# - Java interoperation

Can you give me some pointers on making C# code and Java code interoperate? Let's define the interoperation as something simple: allow (from Java code) the instantiantion and method calling of a class defined in C#, and, possibly, the other way around as well. Is this even possible natively? (i.e. without some proxy/skeleton interface ...

C# how to add Excel Worksheet programatically Office XP / 2003

Hi all, I am just starting to fiddle with Excel via C# to be able to automate the creation, and addition to an Excel file. I can open the file and update the data and move through the existing worksheets. My problem is how can I add new sheets? I tried: Excel.Worksheet newWorksheet; newWorksheet = (Excel.Worksheet)e...

Turning C# methods into C++ methods

I'm exploring various options for mapping common C# code constructs to C++ CUDA code for running on a GPU. The structure of the system is as follows (arrows represent method calls): C# program -> C# GPU lib -> C++ CUDA implementation lib A method in the GPU library could look something like this: public static void Map<T>(this ICollec...

Interop Controls not picking up XP Styles

I created an Interop user control in VS2005. When the user control is shown inside VB6, it does not pickup/use the XP styles (The buttons and the tabs look like VB6 buttons/tabs). How do I get the XP styles to work with my control while it is in VB6? ...

Accessing Win32 C/C++ struct members from C#

I am intercepting Win32 API calls a native dll or exe is doing from C# using some kind of hooking. In this particular case I am interested in DrawText() in user32.dll. It is declared like this in Win32 API: INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags) The LPRECT struct has the following signature (als...

Can someone explain the benefits of using a Primary Interop Assembly in .Net?

This concept is new to me, and a colleague suggested it. Sadly, I had no idea what he was talking about. Can someone enlighten me? ...

Explanation of SendMessage message numbers?

I've successfully used the Windows SendMessage method to help me do various things in my text editor, but each time I am just copying and pasting code suggested by others, and I don't really know what it means. There is always a cryptic message number that is a parameter. How do I know what these code numbers mean so that I can actuall...

Ruby to Python bridge

Hello I am interested in getting some Python code talking to some Ruby code on Windows, Linux and possibly other platforms. Specificlly I would like to access classes in Ruby from Python and call their methods, access their data, create new instances and so on. An obvious way to do this is via something like XML-RPC or maybe CORBA but ...

F# declared namespace is not available in the c# project or visible through the object browser

F# declared namespace is not available in the c# project or visible through the object browser. I have built a normal F# library project, but even after i build the project and reference it to my C# project, I am unable to access the desired namespace. I am also unable to see it in the object browser, i get an error telling me that it ...