interop

What happens if a .NET 1.1 and .NET 2.0 COM object are used in the same process?

If a process loads both a .NET 1.1 COM object and a .NET 2.0 COM object, both using an in-process server, what happens? Does anything break with this configuration? Or would it be safer to make one of the objects an out-of-process server? ...

Empty WS_XML_BUFFER when sending an object parameter

I'm attempting to write a WCF process that retrieves updates from a number of WWSAPI processes. These could take a number of forms, so I'm using objects as the parameter and return value to make it as generic as possible. However when it gets to the WWSAPI side of things, the object parameter is an empty WS_XML_BUFFER. All the HRESULT...

What advantages does pairing .Net development with SQLServer give in terms of ORM?

In Java, Hibernate is king in terms of automating code/DB synchronization. And I'm aware NHibernate is a .NET equivalent, and that LINQ has some cool SQL functions (despite not being developed further IIRC). But, is there any advantage from pairing .Net development with a SQLServer database? Magic automatic persistence of objects perhap...

WPF Thread: "COM object that has been separated from its underlying RCW cannot be used."

I am getting following error: "COM object that has been separated from its underlying RCW cannot be used." I am sure the problem is because COM object is being called not on the thread it has been created - STA. I tried to implement IDisposable but it has not worked for me. There is a couple of posts dealing with similar problem but ...

Interoperability between System.Windows.Forms.Application and System.Windows.Application

Hello, I have to integrate a WPF UI into a .NET 2.0 application. ObservableCollection needs to be modified in the GUI Dispatcher thread, so I came up with a solution involving InvokeLater() ObservableCollection<Item> items; public delegate void AddItemDelegate(Item i); public void AddItem(Item item) { System.Windows.Application.C...

Java stored procedures as Java / .Net interop

I'm looking for a way to access a Java API from both a Java console application and an ASP.Net application. In short my Java API exposes a series of methods for dealing with invoices. All of these methods are essentially commands e.g. GenerateAllInvocies GenerateInvoiceNumber PrintAllInvoices PrintInvoiceNumber All methods will inte...

C++/cli -> calling c# dll -> calling OpenFileDialog issue

Hello Everyone, I write extensions to a C++ program. I write standard C/C++ dlls and I use IJW to call C# dlls. This has always worked perfectly until I wrote and called a C# dll that in turn called an OpenFileDialog and a SaveFileDialog. Whenever either was called with ShowDialog, the app would freeze. So in making a "Minimum Worki...

P/invoke function taking pointer to struct

Functions such as CreateProcess have signatures taking several pointers to structs. In common C programming I would likely pass NULL as a pointer for the optional parameters, instead of creating a temporary struct object on the stack and passing a reference. In C#, I have declared it as (p/invoke) [DllImport("kernel32.dll", CharSet = ...

How do I protect my C# app from crashing when calling a method in an unmanaged DLL?

I have an unmanaged DLL written by another developer in unmanaged C++. My application is a WinForms application written in C#. I am using interop to call a method (function) in the native DLL. The call is causing my application to crash upon executing the method. How does one safely call a method using interop, so that it does not bring...

Good way to script regasm and gacutil for a COM Interop DLL on a developer machine

I'm working on a .NET library that is intended to be consumed in a VB6 project. To set up the dll to be used on my developer machine, I use regasm and gacutil, like so: regasm /tlb:MyDll.tlb Mydll.dll gacutil /i Mydll.dll On each subsequent call, I also unregister/uninstall the assembly: regasm /u /tlb:MyDll.tlb Mydll.dll regasm ...

OCX component in C# - using and deploying

I am creating C# application that uses OCX component. I have this component from manufacturer of some kind of printer. During installation of their files, foo.ocx was added to my C:\Windows\System32. The only thing I had to do is add reference in Solution Explorer, and point that library in COM tab. Then I took interface: [Guid("XXX")...

Inserting Winforms Form inside XAML WPF

I'm trying to integrate a WinForms Form inside a WPF XAML page. I have seen examples of putting Windows Forms controls using WindowsFormsHost, but not for integrating a whole form. Is there a way to do it? The Windows form is hosted inside the WPF application and I'm currently able to load it as a new window but not inside the XAML page...

Multiple seach paths for assemblies not in the GAC when using REGASM & COM

I am in the process of creating a .NET assembly that will be registered for COM so that it can be referenced by Microsoft Excel VBA. The assembly references a third-party .NET assembly (that contains some useful classes) that is not in the GAC, however, I have a problem with the deployment of my assembly since the path to the third-part...

Are there any 'gotchas' involved when invoking BDE through a Delphi COM server or DLL from .NET?

I'm asking this as a follow-up to my previous question: http://stackoverflow.com/questions/3221364/what-is-a-good-way-of-accessing-dbase-files-using-bde-and-delphi It was suggested that I called upon a Delphi COM server instead of passing data though standard input/output, and I totally agree that such a solution is very limited. Basic...

Outlook Interop delivers different results

Hi together, I'm using the Outlook-Interop to read some Events from different calendars and show them on a big screen. On my machine everything works fine (Outlook 2010, Win7 x64), but on the client's pc (Outlook2003, Win XP) the program doesn't find all appointments. If I add some checkboxes for debugging the tool finds between 8 and 1...

.NET Outlook Automation - Ensuring Future Compatability

I'm automating some outlook functionality in a .NET app. It works great. I am compiling it and using v 12.0.0.0 of the Outlook Interop assembly. My code should work on any version of Outlook so it seems silly to have to bind it to a specific version. Is it possible to use reflection to do this instead of compiling a reference? A...

How do I properly pass a Delphi Record to a C# struct with Interop?

In Delphi I have a structure like this: TCustomerInfo = Packed Record CustomerNo: Integer; FirstName: String[50]; LastName: String[50]; End; With a dummy-proc like this: procedure GetCustomer(CustomerNo: Integer; var CustomerInfo: TCustomerInfo); begin CustomerInfo.CustomerNo := 19901; CustomerInfo.FirstName := 'J...

Microsoft Interop Excel closing running instances of excel?

Hey everyone, I've been reading about a lot of people finding it hard to close instances of a running excel application created using Com objects. I've managed to sporadically cause Excel instances to be completely closed however not all the time (I'll get to this later). My problem is rather more complex than simply closing a runnin...

Two-Way Communication Between HTML in .Net WebBrowser and WinForms application

When using WebBrowser control I would like to pass an object from javascript code to C#. Solution is known - using ObjectForScripting property of WebBrowser and invoking methods from javascript code using window.external. I know how to do that, but I would like to create object with given type in javascript and pass it to C# without u...

setlocale() is not affecting ConvertBSTRToString() but system-wide setting does?

Given: ASP.Net application which uses a legacy COM library legacy COM library which is built without Unicode (MBCS) Windows 2008 dev server on which it all runs Needed: support web app users in different locales Test: 1) I set the system locale on the server to Russian and tested Russian inputs. .NET treats them as UTF16, passes o...