Question

I am trying to convert this code to C# .NET Framework 3.5 but that version is not late binding friendly. If I were using 4.0 I'd use a dynamic type but that's not an option right now.

Complicating things is the object I really want to create (atl3270Tool) is created inside a parameter. Help would be appreciated.

Dim atl3270Tool
Dim ErrMsg As String
Dim S_OK As UInt16 = 0
Dim atlDirectorObject = CreateObject("atlDirectorObject.atlDirector")
If atlDirectorObject.CreateTool("3270", 1, True, True, 0, atl3270Tool, ErrMsg) <> S_OK Then
    'Terminate
End If
Was it helpful?

Solution

Late binding is easy to do in vb.net. So take advantage of .NET's support for writing code in different languages, add a vb.net class library project to wrap the COM component.

The "atl" prefix on the identifier name is curious. ATL is an acronym for ActiveX Template Library, a C++ library that is very popular to write COM components. By default it creates servers that support dual binding, both late and early. For early binding you need a type library, it gets embedded into the executable by a default in an ATL project. So make sure that you are not wasting an opportunity here to write early bound C# code. Project + Add Reference, Browse tab, select the DLL. If you get no complaints then you're golden, use Object Browser to look at the generated interop library.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top