Proper way of releasing COM objects?

First – you never have to call Marshal.ReleaseComObject(…) or Marshal.FinalReleaseComObject(…) when doing Excel interop. It is a confusing anti-pattern, but any information about this, including from Microsoft, that indicates you have to manually release COM references from .NET is incorrect. The fact is that the .NET runtime and garbage collector correctly keep track of and … Read more

What is difference between RegAsm.exe and regsvr32? How to generate a tlb file using regsvr32?

regsvr32 will load the library and try to call the DllRegisterServer() from that library. It doesn’t care what DllRegisterServer() actually does – it just calls that function and checks the returned value. You use it to register COM servers in unmanaged DLLs. It can’t generate a .tlb file. regasm will register a COM-exposed .NET assembly … Read more

Is there an embeddable Webkit component for Windows / C# development? [closed]

I’ve just release a pre-alpha version of CefSharp my .Net bindings for the Chromium Embedded Framework. Check it out and give me your thoughts: https://github.com/chillitom/CefSharp (binary libs and example available in the downloads page) update: Released a new version, includes the ability to bind C# objects into the DOM and more. update 2: no-longer alpha, … Read more

How to make SendKeys act Synchronously in IBM Host Access Library

The “Operator Information Area” class seems to provide a solution for this problem. My general case seems to be working correctly with this implementation: Friend Sub PutTextWithEnter(ByVal field As FieldDefinition, ByVal value As String) If IsNothing(field) Then Throw New ArgumentNullException(“field”) If IsNothing(value) Then Throw New ArgumentNullException(“value”) _Presentation.SendKeys(Mid(value.Trim, 1, field.Length).PadRight(field.Length) & “[enter]”, field.Row, field.Column) WaitForEmulator(_Session.Handle) End … Read more

System.Windows.Automation is extremely slow

System.Windows.Automation is EXTREMELY slow. System.Windows.Automation is full of bugs. It may not return all children of an AutomationElement, which is a very severe bug. Apart from that the implementation is not thread safe. System.Windows.Automation is deprecated. Do not use it! In the MSDN you find the following note: UI Automation was first available in Windows … Read more

Handling events from out-of-proc COM server in managed STA application

I’ve found the following excerpt from Adam Nathan’s “.NET and COM: The Complete Interoperability Guide”: If the COM object lives in an STA, any calls from MTA threads are marshaled appropriately so the COM object remains in its world of thread affinity. But, in the other direction, no such thread or context switch occurs. Thus, … Read more

Understanding the Running Object Table

are you running another instance elevated? are you running the exe elevated? When you are a process running as a standard user, you can only see processes/etc that belong to you. So you wouldn’t see processes that are running as administrator. When running with escalated priviliges, you can see all processes belonging to all users. … Read more

What are the differences between using the New keyword and calling CreateObject in Excel VBA?

As long as the variable is not typed as object Dim xmlDocument as MSXML2.DOMDocument Set xmlDocument = CreateObject(“MSXML2.DOMDocument”) is the same as Dim xmlDocument as MSXML2.DOMDocument Set xmlDocument = New MSXML2.DOMDocument both use early binding. Whereas Dim xmlDocument as Object Set xmlDocument = CreateObject(“MSXML2.DOMDocument”) uses late binding. See MSDN here. When you’re creating externally provided … Read more