01-29-2007 03:51 PM
01-30-2007 09:54 AM
...replying to my own posting from yesterday...
I took the time this morning to actually hand-edit each of the "mscorlib" 2.0.0.0 names that were to long for the CVI 8.0.1 .NET controller wizard to handle (there were dozens and dozens of them). It then created the Function Panel, C-source and C-header files, and then stopped when it tried to compile this new instrument driver into the current (empty) project window. I saved the errors into a text file from the wizard's attempt at compiling this driver. Interestingly enough, all the errors were in the header file.
It would be great if someone at NI or where-ever could assist me with completing this, I feel I'm amost there.
Let me know if I should be calling in a support ticket number, or if I should work it out here for all to view.
I can attach the 3 files it created, plus the error list I saved, in a ZIP file to my next posting here.
The ZIP is only 2.3 MB, but explodes to over 40 MB.
In case anyone is curious, I am running WinXP Pro SP2 with all the latest Microsoft patches and updates as of yesterday.
Jumper Bones
01-30-2007 10:57 AM
Hi,
I was able to run CVI 8.0.1 and generate wrapper for mscorlib version 2.0 on my system. I did get the warning/errors dialog from the .NET Controller Wizard with a list of .NET methods it could not generate function panels for as the names were too long. But note that these functions are available in the source and header files; it is just that the names were too long for the FP file. You can still call these functions in your code. If you got errors other than the above, say from the CVI compiler, please do post the errors in this thread. Renaming the identifiers can be tricky because it could result in duplicates or other conflicts - I typically avoid this as I do not care much about the lack of a few function panels.
It did take a long time to compile - this is mainly because the CVI compiler generates a lot of extra information (browse, debug, etc) in debug configuration. Unfortunately CVI cannot process events during this phase, and so appears to hang but it is really just compiling. You can make this considerably faster if you change the build configuration to Release before running the .NET Controller Wizard. Another time-consuming issue you should look out for is the following: if the instrument (.fp) is attached to the source (this what happens by default) then CVI will recompile the source each time it loads the FP and this will again take a really long time in debug configuration. To avoid this, open the generated source in CVI and use the Option >> Create Object File item to generate a .obj file in Release configuration, and then edit the instrument (Instrument >> Edit) and detach it and reattach it to the object file.
By the way, CVI 8.1 ships with the wrapper for mscorlib version 2.0. But this wrapper would not work with CVI 8.0.1 because it uses the newer CVI 8.1 functions for supporting generics.
01-30-2007 03:28 PM
01-30-2007 06:35 PM
02-06-2007 03:59 PM
02-07-2007 09:58 AM
Hi,
I am assuming that you are building a DLL using the generated wrapper files and using the generated .fp file as input for the typelibrary. You are probably exporting the DLL symbols using the generated header file. I tried doing this with the wrapper files in the WebServer dotnet example and ran into two issues:
1) The generated wrappers use struct pointer type definitions to make the handles type-safe. But CVI does not seem to support functions with structs and struct pointers when exporting typelibraries.
2) The FP Class name for each wrapped .NET class is the same as the handle type name. This causes a type redefinition when compiling the ODL.
You can workaround item 2) simply by renaming the FP classes (say by adding a "Class" suffix) in the .fp file.
To workaround 1) you can hack the generated header file and change the handle type-definitions to int typedefs. For example:
typedef int WebServiceX_USZip instead of typedef struct __WebServiceX_USZip * WebServiceX_USZip
And you must also change the CDotNetHandle typedef in cvidotnet.h to:
typedef int CDotNetHandle;
I do not recommend doing the above as it involves changing the library and generated files and losing type-safety of handles. A better approach is to wrap the generated functions in another API that does not use structs, struct pointers, etc - the above hack achieves the same but at the considerable expense of messing up library and generated files.
A type library is normally used when you have to call the DLL from another language (not C/C++). If this is the case, you may want to consider calling the underlying .NET assembly directly in that language rather than going through the CVI generated wrappers. Even if .NET is not directly supported, you can wrap your .NET assembly as a COM (ActiveX) server with typelibrary and call it from your other language/environment. I think this is a considerably cleaner approach.
02-07-2007 10:24 AM