So, in a previous post, we discussed the new unmanaged assemblies that are used in VS.NET 2005. At that time, I mentioned that this had an impact on LabVIEW developers, and as you can guess from the title, it has to do with creating CINs.
CINs, or Code Interface Nodes, are an advanced topic in LabVIEW, but they allow you to call just about any C DLL, regardless of the signature. However, it does mean doing a lot of work yourself in creating the code to glue LabVIEW and the DLL together. When possible, people use the Call Library Node, which handles many common cases. But, if you have a pointer to a structure with pointers, you're going to need a CIN.
I'm not going to explain how to build CINs here - I'm assuming you'll know when it comes time to read all of this post, but you can check out the manuals and the examples in <labview>/examples/cins.
If you try to use VS.NET 2005 to compile your CIN, you'll get an error when you try to load it into LabVIEW - This application has failed to start because MSVCR80.dll was not found. Re-installing the application may fix this problem.
Of course, as we know from the previous post, it isn't that it is not installed, but merely that the MSVCR80.dll is an unmanaged assembly. Thus, when the CIN was built, not enough information was stored to tell it where to find the DLL. I'm not sure why this isn't simply part of the link step automatically, but it's not. So, what is going on...
Well, now when you build a DLL or EXE in 2005, it automatically generates a manifest file. This file, as we see below, contains detailed information about what unmanaged assemblies you depend on. Thus the system now knows exactly which version of the assembly to grab.
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
</assembly>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
</assembly>
Unfortunately, our CIN is required to have this file embedded within it, which is the step not done automatically by the C++ linker. So, we have to add the line
mt /manifest foo.dll.manifest /outputresource:foo.dll;#2
Which embeds the manifest into our DLL at resource location #2. Got it? Well, don't worry, we've updated the makefile that is going to ship with the next version of LabVIEW to do this for you. Until then, please feel free to try out my unreleased version of the makefile here.
Comments