Category Archive for: Interoperability

Platform Invoke

Not all the features of Windows API calls are available from the .NET Framework. This is not only true for old Windows API calls but also for very new features from Windows Vista or Windows Server 2008, Maybe you’ve written some DLLs that export unmanaged methods, and you would like to use them from C# as well. You…

Read More →

Running Windows Forms Controls In Internet Explorer

Windows Forms controls can be hosted in Internet Explorer as ActiveX controls. Because there are many different ActiveX control containers; and all these containers do have different requirements on the ActiveX controls, hosting windows controls in any container is not supported by microsoft. Supported containers are Internet Explorer and MFC containers (MFCcontainers were supported first in Visual studio.NET2003). With…

Read More →

Creating a Client with a Sink Object

After you’ve built and registered the .NET assembly, and installed it into the global assembly cache, you can build a client application by using the event sources. Implementing a callback or sink object that implements the IDispatch interface was – using Visual Basic 6.0 – just a matter of adding the with Events keyword, very similar to…

Read More →

Adding Connection Points

Adding support for COM events to the .NET components requires some changes to the implementation of your .NET class. Offering COM events is not a simple matter of using the event and delegate keywords; it is necessary to add some more COM interop attributes. First, you have to add an interface to the .NET project: IMathEvents.…

Read More →

Using a .NET Component from a COM Client

So far, you have seen how to access a COM component from a .NET client. Equally interesting is to find a solution for accessing NET components in an old COM client that i using Visual Basic 6.0, or C++ with MFC, or ATL. COM Callable Wrapper If you want to access a COM component with a .NET…

Read More →

Using COM Objects from Within ASP.NET

COM objects can be used in a similar way to what you have seen before from within ASP.NET. However, there is one important distinction. The ASP.NET runtune by default runs in an MTA. If the COM object is configured with the threading model value Apartment (as all COM objects that have been written with Visual Basic 6.0…

Read More →

Creating a Windows Forms Application

To see ActiveX controls running inside a Windows Forms application, create a simple Windows Forms application project. With this application, you will build a simple Internet browser that uses the Web Browser control which comes as part of the operating system. The form should include a toolstrip with a text box and three buttons. The text…

Read More →

Using ActiveX Controls in Windows Forms

ActiveX controls are COM objects with a user interface and many optional COM interfaces to deal with the user interface and the interaction with the container. ActiveX controls can be used by many different containers, such as Internet Explorer, Word, Excel,and applications written using Visual Basic6.0,MFC (Microsoft Foundation Classes), or ATL(Active Template Library). A Windows Forms application is another…

Read More →

Adding Connection Points

To see how COM events can be handled in a .NET application, first the COM component must be extended. Implementing a COM event in an ATLclass using attributes looks very similar to the events. NET,although the functionlity is different. First, you have to add another interface to the interface definition file COMDemo .idl. The interface_ICompletedEvents is…

Read More →

Threading Issues

As discussed earlier in this chapter, a COM component marks the apartment (STAor MTA) it wants to live in, based on whether or not it is implemented as thread-safe. However, the thread has to join an apartment. What apartment. The thread should join can be defined with the [STAThread] and [MTAThread] attributes, which can be applied to…

Read More →

Back to Top