Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

COM Port access via DLL inside Labview is not possible

Solved!
Go to solution

Hello.

I've written my own DLL in C# for communication during production process.

But always if I want Labview to use this DLL the communication fails at the first step: Opening the com port.

So I removed all of my code and made only a small DLL which opens/closes the com port.

When I execute the command line tool which uses exactly the same dll as Labview, COM port opening is possible.

The com-port can be chosen by adding a Parameter like "COM1" to the .exe file.

The function inside the dll must be called like: communication.open("COM1") and returns a "true" in case of error.

It would be very nice if somebody could help me and find the error.

 

Best regards

 

chosn

0 Kudos
Message 1 of 6
(5,078 Views)

LabVIEW has built-in serial port communication ability  Instrument IO --> Serial. Why are you writing your own DLL to do this?

0 Kudos
Message 2 of 6
(5,070 Views)

Hi, because the functions in the DLL should be used later on different systems (with and without labview).

But normally should be a COM-Port access inside a DLL be possible in Labview?

 

Regards

0 Kudos
Message 3 of 6
(5,061 Views)
Solution
Accepted by jfisch

Hi again.

I changed my dll to output the Exception of my try-catch function during opening the port to a string.

 

System.Security.SecurityException: Fehler bei der Anforderung des Berechtigungstyps "System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
   bei System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
   bei System.Security.CodeAccessPermission.Demand()
   bei System.IO.Ports.SerialPort.Open()
   bei OpenComPortTest.communication.open(String port_selection)
Die Aktion, bei der ein Fehler aufgetreten ist:
Demand
Der Typ der ersten Berechtigung, bei der ein Fehler aufgetreten ist:
System.Security.Permissions.SecurityPermission
Die Zone der Assembly, bei der ein Fehler aufgetreten ist:
Intranet

 

The problem was, that the dll has been on a mapped Network drive.

After moving it to a local drive, it works.

 

Regards

chosn

0 Kudos
Message 4 of 6
(5,053 Views)

@jfisch wrote:

Hi again.

I changed my dll to output the Exception of my try-catch function during opening the port to a string.

The problem was, that the dll has been on a mapped Network drive.

After moving it to a local drive, it works.


This is a .NET security "feature".

0 Kudos
Message 5 of 6
(5,042 Views)

Dear chosn,

 

I want to create a Serial port dll using visual C++,

and i want to use that dll in Lab view application.

Can you please help me to create Serial port dl..

 

thank you

Sunil

Message 6 of 6
(4,866 Views)