LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can C# dll's be integrated with a LabWindows project?

Solved!
Go to solution

gaurav,

 

Please start a new thread and postyour question in a more detailed and complete form.

 

Otherwise people feel reluctant to try to answer it.

 

 

S. Eren BALCI
IMESTEK
0 Kudos
Message 11 of 16
(1,316 Views)

question is very smple i have create a one .dll(dynamic link libarary) file in c# visual studio 2008 and i want to use that dll file in CVI .

 HOW CAN I USE THAT DLL FLE IN CVI. IS IT POSSIBLE OR NOT IF POSSILE THAT GIVE ME ANSWAR

0 Kudos
Message 12 of 16
(1,314 Views)

Right... That will make people answer. Yell at them. This is a board of volunteers mostly.

No one is required to answer any of your questions. And with your attitude... Good luck with that.

0 Kudos
Message 13 of 16
(1,303 Views)

Use the .NET wizard under Tools menu.

 

There are possibly many similar posts in this forum about this issue.

I am sure there is lots of details in CVI documentation, too.

 

They are much more complete than anything I can write here.

 

Good luck..

S. Eren BALCI
IMESTEK
0 Kudos
Message 14 of 16
(1,294 Views)

Okay this is how I use a C# dll. This is outlined in all the previous instructions but hopefully this should clear up the whole process.

 

Firstly make sure that all the functionality that you want to access in you C# dll is defined as public. Obviously only public functions are accessible.

 

Select the project that you want to access the C# dll through. I often create a CVI project that acts as a wrapper for the dll, and call that  - keeps things clean.

 

With the project selected, click on 'Tools' on the menu and then 'Create .NET controller'

 

Click on the 'Specify Assembly by Path' tick box and navigate to the dll you want to add to your project and select it

 

Then click on the 'Browse' button for the Target Instrument, and create a fp file insde the project you are associating the C# dll with. This will also create a .c and .h file along with it which can be added to the project. 

 

You will see all the expose functionality in the .h file which you'll need to include in your projects in the normal way

 

To access the C# dll you need to call the Initialize function first. Then there will be a Create function to provide a handle to the guts of the dll. You can then start call the functions in the C# dll 

 

Finally when you've finished you need to call the Close function

 

Bear in mind that if you pass in a pointer to memory that is created allocated inside a function - for instance an array that is returned, then you will need to call 

 

CDotNetFreeMemory(**pointer**), otherwise you'll leak memory

 

Hope this all helps and good luck

0 Kudos
Message 15 of 16
(1,291 Views)

One last thing that I forgot to mention. Depending on which version of CVI you're running will also determine the newest .NET version

 

In my case I've not yet upgrade from 2010 yet, so I'm limited to .NET 3.5. I'm guessing later version support .NET 4.0 or possibly even 4.5.

 

I seem to recall that if you try and use a .NET component newer than the version your CVI is capable of supporting it will report the fact during the process. 

0 Kudos
Message 16 of 16
(1,286 Views)