NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Why the .net framework 4.0's Dll can't work with Teststand 2010

Solved!
Go to solution

Hi ,

I installed Visual Studio 2010  and teststand 2010 SP1 (4.5.1)on my machine.

I try to call .NET assemblies that the VC++ DLLs built in Visual Studio 2010 from TestStand.

I have read the paper :

"Can I Use Visual Studio 2010 with TestStand and Call .NET Framework 4.0 Code Modules?" in the following link:

http://digital.ni.com/public.nsf/allkb/997B0CA4E590E8F38625771B0073235E.

I following the instruction at the Using the .NET Framework section in Chapter 5 Module Adapters of the TestStand Reference Manual to create a file called seqedit.exe.config with the following content in the <TestStand>\Bin directory:

<?xml version="1.0"?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> </assemblyBinding> </runtime> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" /> </startup> </configuration> .

 

But it can't works out neither. I get a error when i try to load the function from the dll. the error is as below picture showed:

My operation system is chinese version, so i can transte the error message ,It reports:"Can't load the file or programs"G:\Practice\GenWin32Dll\Debug\Genwin32Dll.dll" or one of it's dependencies. This module should include a programs list"Error.png

0 Kudos
Message 1 of 12
(5,040 Views)
Solution
Accepted by topic author Ivan_Chen2012

That error message does not sound like .NET 4 is the issue, rather it sounds like you are missing some dependencies of that dll. Is this a C++\cli dll? If so, perhaps you do not have the required version of the visual studio C/C++ runtime installed on that machine. You can use the Microsoft visual studio depends.exe tool to help look for missing unmanaged dll dependencies (assuming this is a C++/cli dll or that it depends on such a dll).

 

Also is it perhaps possible that this isn't a .NET dll at all? It sounds like that might be the case from the error message. If so, you should be using the C/C++ DLL adapter instead of the .NET adapter.

 

Hope this helps,

-Doug

0 Kudos
Message 2 of 12
(5,024 Views)

 

Hi dug,

Thanks for your reply.

At first, this dll is generated in the Win32 dll project of Vc++ 2010. I think it should be kind of .net dll since it's generated by the .net ADE, right? I test it in the PC which has been installed with the VC++2010 and teststand2010. i can't figure out what kind of dependecies could be missing. Could you tell me how to check which one is missing in the "dependency.exe"? Attached is the screenshot of the window when the dll is open by the dependency.exe.

 

dependency View.png

0 Kudos
Message 3 of 12
(5,015 Views)

Also, i try the C/C++ adpater . It happens the teststand can't recognize this dll at all. see the attached below:

C Adapter.png

0 Kudos
Message 4 of 12
(5,014 Views)

The reply is highly appreciated.Thanks.

0 Kudos
Message 5 of 12
(5,013 Views)

In this case,what else do i need to install?

0 Kudos
Message 6 of 12
(5,011 Views)

Hi,

 

I was just looking on your  DepencyWalker shoot.

I wonder if its a .net assembly there is no need for MSVCR100D.dll. So can be sure this is a ordinary dll.

 

You have to use the C/C++ Adapter.

The message box is well, because in a standard from MSVC there are no type information available

In this thread there is an example how to add.

http://forums.ni.com/t5/NI-TestStand/Argument-for-function-not-viewed-able-under-VC-by-teststand/m-p...

 

But a first you should add your stuff manually in a few seconds because have the source code

 

Hope this helps

 

Juergen

 

 

 

 

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 7 of 12
(4,995 Views)

C++ DLLs can be managed code (i.e. .NET code), unmanaged code (i.e. native code), or both. Without more information from you or the dll itself it's impossible for us to know. Did you create this dll project and dll? Do you know what assemblies it might depend on and whether or not it was created as a CLI project? From your screen shot of depends.exe it looks like all of the native dependencies are being found, so it is perhaps a mixed-mode (i.e. both native and managed code) assembly in which case it's possible that there are other .NET assemblies that this assembly depends on, if so, they need to be located in the same directory as this dll or in the GAC, or in the root directory of the executeable file you are using (i.e. seqedit.exe in this case, but if you eventually use a custom user-interface it would have to be in that user-interface's directory). It's also possible that this is a purely native code dll and not a managed dll at all in which case you should be using the C++ dll adapter, though it might be that your function prototype uses types not supported by TestStand (C++ class objects for example). If so you will have to write wrapper functions around those calls.

 

If you can show us some examples of the protoypes of the functions you wish to call we can perhaps determine whether or not you have a .NET project and/or which adapter would be best for calling it.

 

-Doug

0 Kudos
Message 8 of 12
(4,985 Views)

I'm nearly certain this is NOT a .NET dll because the error message you are getting is very similar to this error message which is the english version of the error you get when you specify a non-.NET dll in the .NET adapter. So you should be using the C/C++ DLL adapter instead, you might just need to write wrapper functions around the code you are trying to call if the functions are using unsupported types.

 

-Doug

0 Kudos
Message 9 of 12
(4,978 Views)

Hi Dug,

Thanks for the reply .

It's no doubt that Dll is generated in the Visual C++ 2010 ADE. I just re-compiled and generated it with VC++2010 before i call it in the teststand.

I assuming that the dlls which are generated in the .net ADE suits,such as VC++2010, should be the kind of .net dlls. That will be another questions i need to check out if it's not.

BTW, i have tried to call this dll both in the VC++2010 and Labview2010.They both works well. i used "C calling convertion" setting when i use labview to call the dll.

 

I also tried to use the C/C++ adpater in teststand. it can't go through. The error message is "can't find the 'Add' function int the dll".

Is it possible that you give a try to call this dll for me?  i can't understand why it doesn't work out and get exhauted . Really appreciated if you could help me out.

I am new to teststand 2010 and the exported function is very simple. it just return the sum of the two inputs. See the following is the function prototype of the dll.

 

int add(int x, int y)

{

return x + y;

}

 

Also attached is the dll.

0 Kudos
Message 10 of 12
(4,960 Views)