Wednesday, March 31, 2004

.NET Interop

Yesterday, a coworker of mine was getting frustrated because he was trying to access a COM component from within the .NET framework, and was having no joy. I had written a small test application to access the same component (an OPC Server) a year before, so I sent him the code. He pulled the code into his visual studio project, but still no joy. After much research, we learned that the code would only work on a previous version of the framework (version 1.0). For version 1.1, the code, and in fact the entire solution architecture of using the automation wrapper, would no longer work. After much researching and quite a bit of stop and go testing, I've finally been able to access the OPC server from .NET 1.1 framework. My new test code does a lot more than my previous one did too.

The OPC foundation distributes a core components download which includes runtime callable wrappers (RCW) for the OPC components. These RCW interfaces only work in the .NET 1.1 framework. I was able to use these interfaces to connect to the server, setup I/O items, perform reads and writes, and listen for data change events from the server. This is pretty exciting for me because a lot of the software that our company writes is based off of OPC server information. This gets our foot in the door to doing more development in the .NET framework, which I am a big fan of. Of course, the OPC foundation has already developed a .NET API which will make all of this very easy to do, but you have to be a member of the foundation to get the API. Membership costs $1,500. We used to be members, but we let our membership lapse last year. Maybe we will join again, but if not, at least we have a solution for gaining access from within the framework.

No comments:

Post a Comment