Using evc dll in .net application fails

P

Pankaj S

Hi,

I want to use the EVC dll in my application at two forms (say form1 and
form2), so I wrote a wrapper over dll function in my application. I made the
wrapper class as singleton class. VS.net throws the following exception when
I move from form1 to form2 (or form2 to form1)

An unhandled exception of type 'System.ArgumentException' occurred in
System.Windows.Forms.dll
Additional information: ArgumentException

I'm using Application.Run and Application.Exit to move between form. If I
use ShowDialog to go the form, updating UI controls function from worker
thread doesn't get executed (it wait forever).

Does anyone have faced the same problem? what's the solution in this case?

Thanks in advance,
Pankaj
 
M

Maarten Struys eMVP

The fact that you get the ArgumentException inside
Windows.Forms probably indicates that it has nothing to
do with P/Invoking your native DLL. To switch between
forms you should use either the Show or ShowDialog
method. When using Application.Exit, even though the
application itself does not exit, you terminate the
message pumps and closes all associated application
windows. The issue you have with updating UI elements
from within a worker thread is most likely caused by the
fact that they can only be manipulated from within the
thread in which they were created or via Control.Invoke.
In your situation you should take a look at
Control.Invoke.

Hope this helps.

Regards,
Maarten Struys, eMVP
PTS Software bv
-----Original Message-----
Hi,

I want to use the EVC dll in my application at two forms (say form1 and
form2), so I wrote a wrapper over dll function in my application. I made the
wrapper class as singleton class. VS.net throws the following exception when
I move from form1 to form2 (or form2 to form1)

An unhandled exception of
type 'System.ArgumentException' occurred in
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top