Jump to content

.NET Drag Drop error


Recommended Posts

Hi all.


 


I am trying to call a VB .NET application develloped in my company.


The Construtor node returns no errors.


However when I use the Invoke Node to call the Show() method, the following error appear: "DragDrop registration did not succeed"


 


post-34903-0-90679400-1424991616.png


 


The application I am trying to call uses drag and drop menus.


But, shouldn't LabVIEW be able to let those run?


Is there a work arround for this?


 


 


I am using LabVIEW 2014 32-bits and .NET framework 4.5.


 


Thanks in advance for all the help.


 


Regards,


Diogo Ribeiro


Link to post
Share on other sites

 

Hi all.

 

I am trying to call a VB .NET application develloped in my company.

The Construtor node returns no errors.

However when I use the Invoke Node to call the Show() method, the following error appear: "DragDrop registration did not succeed"

 

attachicon.gifDragDrop_error.png

 

The application I am trying to call uses drag and drop menus.

But, shouldn't LabVIEW be able to let those run?

Is there a work arround for this?

 

 

I am using LabVIEW 2014 32-bits and .NET framework 4.5.

 

Thanks in advance for all the help.

 

Regards,

Diogo Ribeiro

 

 

By application and your description I presume you mean instantiating an instance of the particular Form that you are showing?

 

Or are you calling the static Main method in the (commonly named) Program class in order to start-up the message pump in order to monitor WND messages?

Link to post
Share on other sites

By application and your description I presume you mean instantiating an instance of the particular Form that you are showing?

 

Or are you calling the static Main method in the (commonly named) Program class in order to start-up the message pump in order to monitor WND messages?

 

Yes, I am trying to call an instance of a Form (the main menu of the application), using the method Show(). The Form is not created before the invoke of the method and I want it to show up, so that I can use through LV.

It indeed shows up (not completely, the menu with the drag and drop capabilities enabled does not show), if I press continue in the mentioned error. 

I have tried this approach with success for a different application that does not have any drag and drop menus.

 

Here are some more details about the error:

 

************** Exception Text **************

System.InvalidOperationException: DragDrop registration did not succeed. ---> System.Threading.ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.

at System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)

 
 
This error does not show up when I start the application through the SO windows menu directly (as a standalone application).
 
Any ideas on the cause of the problem?
 
Thanks for all the help.
Diogo Ribeiro
Link to post
Share on other sites

Hi,

 

************* Exception Text **************

System.InvalidOperationException: DragDrop registration did not succeed. ---> System.Threading.ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.
at System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)

 
 
This error does not show up when I start the application through the SO windows menu directly (as a standalone application).

 

When you run a standalone application, your Form's constructor and the other methods all run in the same thread.

 

However, LabVIEW automatically switches between different threads to run your code. You will get a .NET exception if your Form is accessed from the "wrong" thread.

 

See http://stackoverflow.com/questions/6373645/c-sharp-winforms-how-to-set-main-function-stathreadattribute to get started.

Link to post
Share on other sites

Hi,

 

 

When you run a standalone application, your Form's constructor and the other methods all run in the same thread.

 

However, LabVIEW automatically switches between different threads to run your code. You will get a .NET exception if your Form is accessed from the "wrong" thread.

 

See http://stackoverflow.com/questions/6373645/c-sharp-winforms-how-to-set-main-function-stathreadattribute to get started.

 

Thanks for pointing me in the right direction.

 

It was indeed a thread problem. Since LabVIEW by default uses a multi-thread system (MTA) and Windows Forms need a single-thread system (STA).

 

After some time trying to force, inside the VB code, the thread be an STA.

I found a much simpler solutions in this topic: http://forums.ni.com/t5/Measurement-Studio-for-NET/Calling-net-dll-in-Labview/td-p/803084

In the 1st response by the user nickb.

So by changing the way LabVIEW calls the .NET application in the LabVIEW VI execution properties (change it to "user interface"), my application can now run without any errors.

NickB11-04,%2007_38_27.png

 

Thanks to everyone.

  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By bartek618
      I know how to run .Net executable by MainWindow() constructor but I have some resources defined in App.xaml and MainWindow() doesn't run without them. How to run application starting with App() constructor? Also I need to pass some parameters into MainWindow().
    • By William Hofmeister
      I need to access Aerotech A3200 data with LabView. The Digital Scope in the A3200 software has the capability to record data at 1kHz for 8 seconds in dedicated batches. We use LabView for all functions surrounding the motion control and have the Aerotech LabView package. Using the LabView vis we can only access data a single data point per call and I don't see how to set up a FIFO to Windows LabView. Someone must have looked at this problem lately. Can anyone steer me in the right direction?  Thanks!!
    • By LogMAN
      So this just happened to me and I'm quite confused by it. As it turns out, the .NET Constructor Node not only provides terminals for error in, error out and the reference, but actually two more "hidden" terminals:

      Notice: I left the error terminals untouched and none of the wires are connected (try it yourself). This never occurred to me. Only now, while hunting a null reference exception I found the constructor node looked "off", like this:

      The strange part is that the terminal doesn't actually carry the reference (which is why I receive the null exception). It only specifies the type. The upper left terminal is a void type input, so the wire is always broken.
      Does anyone know why these extra terminals exist? They don't seem to be part of the specification as far as I can tell.
      Any fancy things we can do with this?
    • By ATE-ENGE
      Edit: I'm asking primarily if there is a reason why/when I should/shouldn't use .net functions in my LabVIEW development. The example below is just to demonstrate a case of my question.
      _________________________________________________________________________________________________________________________________________________________
       
      I recently found a custom library that calculates SHA256 hash algorithms However, in this post I see that the same thing can be done with .net 
       
      My main question is: Is there any reason to build or use a custom library for something where .net functionality already exists? Are there any disadvantages to offloading work to .net ? 
    • By Gribo
      Hello, I am trying to copy multiple cells in LibreOffice, using the UNO API. I encountered an issue in the XCellRangeData object.
      The object's method returns an array of array of any() type. it seems LV can't compile this, even though the wire appears not to be broken. If I try to parse the array of array into a single dimension and then rebuild, the code is broken. See the attached files. Is there a solution for this issue? The alternative would be to copy cells one by one, which is a much slower solution.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.