Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling LabVIEW from C#

Hi All,

I am using LabVIEW 7.1 on an XP professional machine. I am trying to call LabVIEW from my .NET application and I receive an "Access is Denied" error on the following line of code:

lv = new LabVIEW.ApplicationClass();

I have given the LabVIEW.exe and the LabVIEW.tlb file access permissions for the ASPNET user. Is there any other file I need to give permissions to. In my event viewer it is stating that it is the ASPNET user that is being denied access. I just don't know which file to give the correct permissions to.

Can anyone help.

Thanks,

Jim
0 Kudos
Message 1 of 6
(7,512 Views)
Is this from a Windows Form or asp.net project? I know I have gotten this to work from a Windows Form app without having to make any changes to the security settings

//Instantiate a reference to LabVIEW
lv = new LabVIEW.ApplicationClass();

//Set the path to the VI
string vipath=lv.ApplicationDirectory.ToString() + @"\Examples\General\Strings.llb\Parse Arithmetic Expression.vi";

//Get reference to that VI
vi= lv.GetVIReference(vipath,"",true);

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 6
(7,509 Views)
Hi Bilal,

I am trying to instantiate LabVIEW from the code behind an aspx page.

Jim
0 Kudos
Message 3 of 6
(7,509 Views)
See the Microsoft KB article Process and request identity in ASP.NET, specifically the section regarding starting out-of-process COM servers. LabVIEW is an out-of-process COM server, so you need to give the local ASPNET account launch permissions via DCOM Config. Here are the steps to do this in case you're unfamiliar with it:


  1. Go to Start->Run, then type dcomcnfg.exe, then click OK.

  2. Expand Component Services, then Computers, then My Computer, then DCOM Config.

  3. Scroll to LabVIEW Application, right-click on it, then click Properties.

  4. Click the Security tab, go to the Launch Permissions section, click Customize, then click Edit.


  5. i>In the Launch Permission dialog, click Add.
  6. In the Select Users or Groups dialog, click Locations and select the local machine, then click OK. Then in the text box at the bottom, enter ASPNET, then click OK. When you get back to the Launch Permission dialog, you should see an entry for ASP.NET Machine Account ([Machine]\ASPNET), where [Machine] is the name of the local machine.

  7. Click OK to close the Launch Permission dialog, then click OK to close the LabVIEW Application Properties dialog.

  8. Make sure that all instances of LabVIEW are closed, then try your ASP.NET page again.



Hope this helps.

- Elton
Message 4 of 6
(7,509 Views)
Elton,

Thanks so much. That worked like a charm.

I'm off and running.....

Jim
0 Kudos
Message 5 of 6
(7,508 Views)
Guys, what references (or any other dependences) do I need in order to call the LabVIEW.ApplicationClass() ?
0 Kudos
Message 6 of 6
(7,149 Views)