interop

callback function from unmanaged dll in VB .NET

I'm trying to use an unmanaged dll in VB.NET. The example source code provided with the dll is in VB6 and below is my attempt to convert it to .NET. When the dll tries to do a callback I get a "Attempted to read or write protected memory" exception. I really don't care about the callback function getting actually called. My code: <DllI...

How do you capture the text on the first page of a Microsoft Word document?

Using VB.NET how do you capture the text on the first page of a Microsoft Word document? I've imported the Word 12 interop library (for Word 2007), and I know how to use the document.range function, but how do you know which page you're on when you're selecting text? ...

Excel dll for Microsoft.Office.Interop.Excel

We want to use Microsoft.Office.Interop.Excel in our web application. Everything works fine on our local machines, but on our test machine we're running into problems. It has neither Visual Studio nor Office installed on it. We're using .NET framework 2.0 and the server is running on Windows Server 2003 with IIS6. Is there a dll that ...

Connect to .Net software program and interact

I'm not sure how to come across to ask this, but I'm trying to figure out if there is possibly a way by which I can access a running process written purely in .Net and interact with its memory space and active objects. I do Add-in development for 2 point-of-sale packages, and am trying to figure this out for analysis of data entry in an...

Simplest way to move an array from C++ to C#, modify it, and pass it back to C++

I have a C# class library that contains methods that need to be used with an external application. Unfortunately this external application only supports external APIs in C/C++. Now I've managed to get a very simple COM example working between a C++ dll and a C# DLL, but I am stuck on how I can move around array data. This is what I'v...

Loading/Using Resource Dictionaries from a WinForms hosted WPF control

I have a Windows Forms application that needs to host a WPF control at runtime. I have the basic hosting and interaction complete (using an ElementHost control) and everything works fine until I try to do something that requires the WPF control to make use of some custom resource dictionaries that are defined. (The WPF control and all of...

How do I get a System.Windows.Form instance from its Win32 handle?

The following code implements a simple singleton that ensures only 1 instance of my application can be run. However, if another instance is started, I need to be able to grab that instance's command-line arguments, pass them to the initial instance, then terminate the second instance. The issue comes in when I'm attempting to get hold o...

Attempted to read or write protected memory at System.Web.Hosting.UnsafeIISMethods.MgdGetSiteNameFromId

I'm getting an AV when I hit a COM interop ASP page (that calls managed .NET code). Feels like this has something to do with IIS 7 / Windows 2008. Google can't figure this out. Any ideas? Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at System.Web.Hosting.UnsafeIISMethods.M...

On-the-fly upgrading a COM object used in a .NET application

We have a large, deployed, 3-tier .NET application which for good business reasons can't be upgraded at present. The client makes use of a number of classic c++ ActiveX controls through the usual interop mechanism. We have fixed some critical bugs in one of the ActiveX controls and need to deploy the fixes to a number of customers with...

Setup Project COM Registration

I have an IE BHO (a toolbar) written in C#/.NET 2.0 using COM Interop. I'm using Visual Studio 2005 to generate an MSI installer for my toolbar using the Setup Project. In my assembly, I have COM register/unregister methods using the ComRegisterFunctionAttribute, which set the registry keys that give IE some key information about my to...

I want to know what functions are available from a Win32.DLL

I have a DLL file that has some helpful functions I want to call in my application. Unfortunately I don't have the documentation for it any longer. Is there any way I can discover what are the functions exported by the DLL and their method signature? Maybe there's a utility that lists the functions and their arguments. Know of any? ...

Fastest way to call a COM objects method without using a RCW

I'm trying to find the cleanest and fastest way for calling a COM objects methods. I was using a RCW for the object but every time a new version of the third party COM object comes out its GUID changes which then renders the RCW useless, so I had to change and start using Type mytype = Type.GetTypeFromProgID("MyCOMApp.Application");...

Implementing IProvideClassInfo on C# COM Object

I'm trying to implement the IProvideClassInfo on a C# COM object so it's events can be used from Windows Script Host (WSH). I've managed to implement the interface and trace a call in to my GetClassInfo method. However, hooking up the events fails with "Cannot connect object". Has anyone managed to do this? This is my script code (JSc...

64 bit C# with a 32 bit VB6 COM object

I have a 32 bit in-proc STA VB6 dll. I sadly cannot do anything about this. My C# component greatly benefits from being 64 bit. Is there anyway to call/interface with this 32-bit dll from my 64 bit process? Any sort of wrapper or anything? ...

C# program (process) will not unload

I have a C# program that uses a class from another assembly, and this class calls an unmanaged DLL to do some processing. Here is a snippet: public class Util { const string dllName = "unmanaged.dll"; [DllImport(dllName, EntryPoint = "ExFunc")] unsafe static extern bool ExFunc(StringBuilder path, uint field); public bo...

C# Interop with C vs Interop with Java: Which is better/easier/faster?

I have an application in C# that currently authenticates to LDAP. We want to extend functionality to support IBM's Tivoli Access Manager, which is comprised of a Policy Server, and an LDAP server (and other modules as well). Unfortunately authenticating with the LDAP server for our customer is not acceptable, thus we must bind with the p...

WPF Window created from WinForms sometimes stops redrawing

I have a borderless, topmost, clickthrough WPF window that's used to display a notification message to the user that appears and then fades away, and it's created from a WinForms app when I click a button (this is a test project). Clicking the button multiple times creates several instances of this window. Most of the time it seems to...

VS 2005 against Office XP PIA on system with Office 2003/2007?

On my development system, I am running Office 2007, and previously had Office 2003 installed, and thus have the Microsoft Office 11.0 and 12.0 Object Models available. Our production environment is in the process of being upgraded to Office 2007, but it hasn't happened yet - still running Office XP in production, and I need to be able t...

Permissions Error Registering Assembly

I've waited a long time for concensus on moving from IIS to the built in web server for debugging our web application, one of the main reasons being that I don't always have to run VS as admin. We now have a COM dll included (exported by) in the solution, and on build it, VS tries to register this and complains because my regular user d...

Calling a VB6 method from a .NET DLL

I have a DLL written in VB 6 and another DLL written in Visual Studio 2005 (VB.NET). Now I want to invoke the method of the VB DLL from my .NET DLL. What should I do for this? Any thoughts? ...