Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Notify GPIB service request error in .NET 2.0?

Hi...
 
I'm using following program.
 
NI GPIB driver version 2.4 ( dotNet assembly 7.1.0.273)
Visual studio 2005 express C#.
dotnet framework 2.0
 
When I used vs2003 , I had no problem of following code (from NI dotnet example)
----start code---------
private void notifyOnDSRButton_Click(object sender, System.EventArgs e)
        {
            try
            {
                testDevice.Notify(GpibStatusFlags.DeviceServiceRequest, new NotifyCallback(testDevice_Notify), "Sample user data");
            }
            catch(Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }
----end code--------
but When I use above code in dotnet 2.0 and visual c# 2005, I met following run time error.
 
A call to PInvoke function 'NationalInstruments.NI4882!f::a' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
 
and If I ignore above error, I met "cross thread error".
 
I read some article about that error at usenet, they said this is dotnet 2.0 feature of thread.
 
I think NI's new dotnet assembly 8.x.x could solve this type of problem, but you does not provide 8.x.x dotnet assemnbly in your official gpib driver.
 
How can I use gpib service request notify callback function?
 
--oldfark---
 
 
 
 
 
0 Kudos
Message 1 of 4
(5,821 Views)
Hi Old Fark,

I'm not sure exactly what's causing your issues here. We may very well have a .net assembly you can download that will correct this issue. I've moved the question up the chain of command and hopefully we'll have more information for you shortly.

Regards,
Matt S.

LabVIEW Integration Engineer with experience in LabVIEW Real-Time, LabVIEW FPGA, DAQ, Machine Vision, as well as C/C++. CLAD, working on CLD and CLA.
0 Kudos
Message 2 of 4
(5,799 Views)
Hi Old Fark,

From the higher-ups...

"We do support running in debug mode. If he runs a debug build, everything will work just fine. This error is occurring while he's running his debug build in Visual Studio. And it's not really an error in this case - he can select "Continue" and keep right on going. He can also select to disable that particular Managed Debug Assistant for that project in the Build>>Exceptions menu. I ran into this problem while testing that our current builds of GPIB worked under Famework 2.0 and VS2005. I've run all of our automated tests in both release and debug modes to confirm that there is in fact no stack corruption or other issue "...." his best bet is to disable that MDA for his project."

So it appears that you should be able to run in debug mode by correcting a couple of settings.

As far as the cross thread error you're getting, we will need a bit more information to resolve this issue for you. Could we possibly get a look at your notify() callback?

Regards,
Matt S.

LabVIEW Integration Engineer with experience in LabVIEW Real-Time, LabVIEW FPGA, DAQ, Machine Vision, as well as C/C++. CLAD, working on CLD and CLA.
0 Kudos
Message 3 of 4
(5,783 Views)
thank you Matt

I tested it again.
And find sometimes it works well, but sometimes Notify failed to tirgger it.
I don't know the exact reasion of that, but I guess my instrument have some bugs in GPIB SRQ response or OS have some problem.

For cross thread error , I solved problem using following code.

Control.CheckForIllegalCrossThreadCalls = false;

Regards

oldfark
0 Kudos
Message 4 of 4
(5,707 Views)