.NET Questions and Solutions

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘COM’

FIX: Access Violation When You Migrate MTS Application to COM+

Symptoms
When you migrate a Microsoft Transaction Server (MTS) application to COM+, and you do not call the SetComplete or SetAbort method, an Access Violation may occur, and the application may fail (crash). This problem occurs in COM+ (Windows 2000 Service Pack 1) and not in MTS.
Resolution
This problem occurs when non-root transactional objects release the object reference to their parent object and do not call SetComplete or SetAbort explicitly at the end of the method.
This problem is caused by a difference in the activation and deactivation mechanisms between COM+ and MTS. In COM+, if the child object does not set the done bit to true (if it does not call the IObjectControl::SetComplete or the IObjectControl::SetAbort method, does not call the IContextState:setCompletion method, or does not use Auto-Completion), the COM+ interception layer deactivates the parent object before the child object. In fact, you do not need to set the done bit, even if it is preferred in most situations.

BUG: You receive a “Type mismatch” error message when you assign a value type variable to a property through COM InterOp in Visual Basic .NET or in Visual Basic 2005

Symptoms
When you assign a value to a property of a Component Object Model (COM) object in .NET, you may receive the following error message when you run your application:

An unhandled exception of type ‘System.Runtime.InteropServices.COMException’ occurred in InterOpDemo.exe
Additional information: Type mismatch
Resolution
The problem occurs if all of the following conditions are true: You are using the COM object in early bound mode.The property in the COM object has both Set and Let methods.You are trying to pass a value type variable to that property. In early bound mode, Microsoft Visual Basic .NET and Visual Basic 2005 always call the Set method of the property if it is available. If you want to call the Let method, you must explicitly specify it.