LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

my ActiveX server can't be generated from the .idl file.

I am using Labwindows/CVI 7.1.

I intended to build an ActiveX server to implement and export the functions as COM METHODs. After I defined the interfaces and methods with the wizzard, Labwindows/CVI generated the source file (.c), the include file (.h) and the interface descriptions (.idl). I would like to build my ActiveX server as DLL, but during the compiling an error occurs: "MIDL 2026". I read about this error code, but I doesn't say too much for me, at least nothing reasonable. I also read some topics about this problem on NI pages. I've already tried to compile with midl.exe from command prompt.

What did I do wrong? Will I get a dll with "Com methods" if the compilation is ready?

Thank you for your reply.

Roland
0 Kudos
Message 1 of 9
(4,434 Views)
I saw some links pointing to a possible incompatibility when upgrading MIDL, VC, or the SDK. See:
http://blogs.msdn.com/mikewasson/archive/2006/10/02/MIDL-error_3A00_-_2700_annotation_2700_.aspx

Also, search for the "MIDL2026" in http://msdn2.microsoft.com/en-us/library/default.aspx

Did you get the same error when manually compiling with MIDL? Does the error point to a particular line in your IDL file?
Have you tried building the sample ActiveX servers (samples/activex/servers) that ship with CVI?
Could you post all your files (zipped) so others can try with their installations of CVI?
0 Kudos
Message 2 of 9
(4,416 Views)
Hello Mohan,

first of all, I want to tell you that I tried to build the sample ActiveX server and it worked on my computer (of course). I will go through the code
in details, although I did it many times.  (8D  I think that will go easily, so I will be able to build my own ActiveX then. I am really happy that I can
see the exported functions as "com method" in the dll with DLL Export Viewer.
Normally I am seeking for the examples with the CVI example browser and I didn't check that samples/activex/servers/SimpleDLL folder.

Anyway, I tried to compile the server with MIDL from prompt, but it didn't say that in which line I have problem. I had to include the sdk/bin/include folder
(if I remember well) as you told to somebody on this forum.
Now as I'm watching my code, it seems I forgot to implement the DllMain function as well and who knows what else.  (8D

This is a very new field for me and although I went through the tutorial: Building ActiveX Servers in LabWindows/CVI, there are many small details I have to learn first.

So thank you very much for your hints, again.  😉
0 Kudos
Message 3 of 9
(4,402 Views)
Hello Mohan,

I did a very simple AcitveX server, which has only one method: Add() to add 2 numbers. The CVI compiles the server as dll. I can use my method.
But when I try to compile a bigger project, then I get the MIDL 2026 error code.

I attach my ActiveX server's files as you asked. It is pretty big, I hope you can find some thing. I have to mention that the only thing I did differently in this project
from my first one (in which I have the method Add() ) is I created my own variable types. You can find them at the beginning of the MyActiveX_Server2_axs.h:

/******************************************************************************/
/* Type definitions                                                                                        */
/******************************************************************************/

 typedef char* IFdtContainer;
 typedef char* IFdtCommunication;
 typedef BSTR FdtXmlDocument;
 typedef BSTR FdtUUIDString;
 typedef BSTR FdtXPath;

Thank you for your help in advance, but I will keep on try to compile it.

Roland
0 Kudos
Message 4 of 9
(4,396 Views)
I think I was right.
The problem is about my own variable types. I think they should be defined as interfaces? Is that true?
At this point I really can't get through. There is a sample about datatypes in folder National Instruments\CVI71\samples\activex\servers\Datatypes, but I don't
know werther this is the solution in my case? A datatype as an interface?   😞

this link may relate to my topic: http://forums.ni.com/ni/board/message?board.id=180&message.id=3490&requireLogin=False .

Roland


Message Edited by b_roland on 02-06-2008 02:33 PM
0 Kudos
Message 5 of 9
(4,390 Views)
I tried to compile my .idl file from command window and I got the next error:

C:\Program Files\National Instruments\CVI71>"sdk\bin\midl.exe" /cpp_cmd "\bin\preprocessor.exe" /I "sdk\include\oaidl.idl" "D:\BorbelyR\myWORKS\MyActiveX_Server2\MyActiveX_Server2_axs.idl"

Microsoft (R) 32b/64b MIDL Compiler Version 5.03.0279
Copyright (c) Microsoft Corp 1991-1999. All rights reserved.

Processing D:\BorbelyR\myWORKS\MyActiveX_Server2\MyActiveX_Server2_axs.idl
midl : command line error MIDL1001 : cannot open input file objidl.idl

As you can see, I added the oaidl.idl file as input, but then it missed the objidl.idl file.
0 Kudos
Message 6 of 9
(4,378 Views)
Hi Roland,

I think you are on the right track. CVI only supports Automation types for method parameters and properties. You are using custom types and this is not supported in CVI generated ActiveX servers. While you can enter any identifier for the type in the 'Edit Parameter' and 'Edit Property' dialogs, the identifier should either be one of the pre-listed Automation types or an interface type. Having said that, I did see that all your typedefs are to BSTR and char*. You can just use 'string' instead of your type in the Edit Parameter dialog for BSTR. I am not sure if your char* types refer to a character address, array, or C-style string. If it is a C-style string, you should again just use 'string' in the CVI dialogs to keep your server automation/CVI-compatible. The 'string' type essentially becomes a BSTR in your IDL, but CVI converts the BSTR to C-string in the code that you have to implement. If your char* refers to a scalar pointer, you should instead use an input/output char parameter. If your char* refers to an array, then you can choose 1D array in the dimension ring. It you really, really want to keep your typedefs, then you could also try adding them by hand to the generated IDL file before building - this may also work but is not recommended. I think you added the typedefs to the generated header file - changing the generated header file by hand is also not recommended as you will lose these changes if you ever regenerate the files from CVI.

0 Kudos
Message 7 of 9
(4,375 Views)
The /I switch to MIDL should point to include directories and not files. You should just pass sdk\include for this switch. You may also want to add the /tlb switch to the MIDL command-line. Also, I would recommend always using full-paths with MIDL - sometimes it can get confused by relative paths.

If you are able to build the sample servers, then the problem is probably your use of custom types. MIDL can be very misleading about the errors it reports - so if you either add your typedefs to the IDL or replace your types with automation-compatible types in the CVI wizard and regenerate the files, then it should probably work.
0 Kudos
Message 8 of 9
(4,370 Views)
Yesterday I just had to go, so I couldn't answer to you. I think I will choose the original automation datatypes, then it will work. I need only string and sometimes boolean. The point was that to use my types to make it clear for the user. So I change everything to "basic" types, then it will work.

About the MIDL I want to say that I used the path first with the /I switch, but nothing happened, after I added the filename as well, then started to compile.  (?) But compiling from prompt is not necessary from now.

Thanks for the help.

Roland


Message Edited by b_roland on 02-07-2008 06:55 AM
0 Kudos
Message 9 of 9
(4,357 Views)