Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

CWData cannot be used as a parameter of an interface in VB.NET 2005

Hi all,
 
I am upgrading an application from vb.net 2003 to 2005 which uses DataSocket for connection. After it is upgraded, the interface class that i wrote has errors. After few trials, I found the problem is that CWData type in the actual parameter list of the Sub in the interface cannot be recognized. I have tried to remove and add the references, but seem it doesn't help. Can anyone tell me why this would happen? Thank you!
 
CY
0 Kudos
Message 1 of 11
(5,101 Views)
Hi CY,

Exactly how are you upgrading your application? Why are you using CWData and not the native DataSocket .NET assemblies?  Can you post the error you are getting?

Have a great day,

Ecleamus Ricks, Jr.
National Instruments
Applications Engineer
0 Kudos
Message 2 of 11
(5,085 Views)
Hi Ecleamus,
 
Thank you for your reply. I now try to post the related codes and errors here.
 
Public Interface IDSCallback
    Function NewAsynchCommand(ByVal CmdData As CWDSLib.CWData, _
                ByRef ReplyData As CWDSLib.CWData, ByVal DSKey As String) As structMonitor
 
    Function NewAsynchCommand(ByVal CmdData As CWDSLib.CWData, ByVal DSKey As String)
 
    Sub NewAsynchReply(ByVal ReplyData As CWDSLib.CWData, ByVal DSKey As String, _
                ByVal RemoteMonitor As structMonitor)
End Interface
 

Public Class frmMain Implements IDSCallback
    Public Function NewAsynchCommand(ByVal CmdData As CWDSLib.CWData, _
                ByVal DSKey As String) Implements IDSCallback.NewAsynchCommand
    End Function
 
    Public Function NewAsynchCommand(ByVal CmdData As CWDSLib.CWData, _
                ByRef ReplyData As CWDSLib.CWData, ByVal DSKey As String) _
                As XDAQTYPELIB.clsGlobals.structMonitor _
                Implements IDSCallback.NewAsynchCommand
    End Function
 
    Public Sub NewAsynchReply(ByVal ReplyData As CWDSLib.CWData, _
                ByVal DSKey As String, ByVal RemoteMonitor As structMonitor) _
                Implements IDSCallback.NewAsynchReply
    End Sub
End Class
 
The reference to CWDSLib (ActiveX) is included and it works well with VB.NET 2003. After it is upgraded to VB.NET 2005 by the convertion wizard, the following errors occurs:
 
Error 155 Class 'frmMain' must implement 'Function NewAsynchCommand(CmdData As CWDSLib.CWData, ByRef ReplyData As CWDSLib.CWData, DSKey As String) As clsGlobals.structMonitor' for interface 'IDSCallback'.
Error 156 Class 'frmMain' must implement 'Function NewAsynchCommand(CmdData As CWDSLib.CWData, DSKey As String) As Object' for interface 'IDSCallback'.
Error 157 Class 'frmMain' must implement 'Sub NewAsynchReply(ReplyData As CWDSLib.CWData, DSKey As String, RemoteMonitor As clsGlobals.structMonitor)' for interface 'IDSCallback'.
Error 162 'NewAsynchCommand' cannot implement 'NewAsynchCommand' because there is no matching function on interface 'IDSCallback'.
Error 164 'NewAsynchCommand' cannot implement 'NewAsynchCommand' because there is no matching function on interface 'IDSCallback'.
Error 171 'NewAsynchReply' cannot implement 'NewAsynchReply' because there is no matching sub on interface 'IDSCallback'.
 
The above errors will go out if CWDATA is replaced with String in the actual parameter list. So I guess it is the problem of CWDATA. Could you see why this would happen?
 
 
Cheers,
 
CY
0 Kudos
Message 3 of 11
(5,072 Views)
For additional, I use Measurement Studio 8.0.0 which is upgraded from 7.1 and Measurement Studio 8.0 for VS 2005 Patch has been installed.
0 Kudos
Message 4 of 11
(5,072 Views)
Hi CYLee,

I suggest installing the 8.0.1 upgrade for Measurement Studio which provides full integration with Visual Studio 2005.  Refer to this discussion forum for more information.  I do not get any errors when I use the conversion wizard (I have 8.0.1) so this is most likely the reason.  If upgrading does not resolve your issue, please post the simplest form of your code that will allow me to reproduce this behavior on my end.

Have a great day,
Ecleamus R
0 Kudos
Message 5 of 11
(5,042 Views)
Hi Ecleamus,
 
I have tried to install a fresh copy of WinXP and VS2005 (with updates), and MStudio8.0.1 evaluate version. I created the following simple code but the same errors still present.
-------------------------------------------------------------------------------------------------------------------------------------------------

Imports

CWUIControlsLib

Public

Interface Interface1

      Sub Test(ByVal s As CWUIControlsLib.CWData)

End

Interface

-------------------------------------------------------------------------------------------------------------------------------------------------

Imports

CWUIControlsLib

Public

Class Class1

   Implements Project2.Interface1

      Public Sub Test(ByVal s As CWUIControlsLib.CWData) Implements Project2.Interface1.Test

      End Sub

End

Class

--------------------------------------------------------------------------------------------------------------------------------------------------

Error 1 Class 'Class1' must implement 'Sub Test(s As CWUIControlsLib.CWData)' for interface 'Project2.Interface1'.

Error 2 'Test' cannot implement 'Test' because there is no matching sub on interface 'Project2.Interface1'. 

-------------------------------------------------------------------------------------------------------------------------------------------------

It is really a big problm for my software development if it cannot be solved. Thank you for you help.

0 Kudos
Message 6 of 11
(5,008 Views)
Hi CYLee,

Thanks for the sample code.  I was able to reproduce the behavior on my end.  The cause of the error is due to conversion wizard not handling the references to other projects sufficiently.  In order to resolve these errors:
1. Note the path of the reference to Project2 dll
2. Remove the reference
3. Add Project2 reference by browsing to the path of the actual .dll

Additionally, I want to stress that we do have a .NET API which includes assemblies for DataSocket.  Refer to the Measurement Studio help for detailed information.  As well, there is DataSocket example code in:
C:\Program Files\National Instruments\MeasurementStudioVS2005\DotNET\Examples\DataSocket folder.

Have a great day,

Ecleamus Ricks, Jr.
National Instruments
Applications Engineer
0 Kudos
Message 7 of 11
(4,985 Views)
Hi Ecleamus,

Your solution works! I have to add a reference to the DLL instead of the project folder. Thank you for your help! By the way, could you tell me the differences between Interop.CWDSLib.CWData and NationalInstruments.Net.DataSocketData? I used the former for my application development with VB6 at the beginning and it still works until now with VB.NET2005. Why you would suggest me to change? Thanks again.

Best,
CYLee
0 Kudos
Message 8 of 11
(4,966 Views)
Hello CYLee


The Interop.CWDSLib classes are auto-generated by Visual Studio 2005 and allow you to talk with the underlying datasocket activex component using .NET Interop. Since this is auto-generated, it is not as easy to use sometimes. The classes under the NationalInstruments.Net namespace also talk to the same datasocket activex component, but these are hand-written wrappers, they have the following advantages

- They are well documented and the help topics are integrated into the VS2005 help system
- They are organized to take advantage of .NET types. Not everything is an object as is the case with auto-generated wrappers.
- They provide better resource management than the auto-generated wrappers via the Dispose() pattern.
- much more...

Overall, they provide a better user experience than using the auto-generated wrappers. There are significant differences between VB.NET 2005 and VB 6.0 and while the upgrade wizard helps, it cannot completely take care of all upgrade issues. You probably know about this already, but there are alot of resources available online that explain the differences between VB.NET and VB 6.0.

But to summarize, the
NationalInstruments.Net classes are designed and tested for use with VS2005 and are more intuitive and easy to use than the auto-generated wrappers. Measurement Studio 8.0.1 or higher provides VS2005 and VS2003 support.

Hope this answers your question.
Bilal Durrani
NI
0 Kudos
Message 9 of 11
(4,949 Views)
Hi Bilal,

Thank you for your useful information. I finally decided to upgrade the application manually to VS2005 by manually creating a new project and adding back all the forms/classes and the NI.NET library. After the migration, I found everything is OK except the DataSocket communication. The application can be built without error and can be executed. But when the codes for datasocket are run, there is an error displayed in the Output window of VS2005.

"A first chance exception of type 'System.NotSupportedException' occurred in NationalInstruments.Net.dll"

How can I see what the error is about? Is there a way to catch it?

Thanks,
Dicky

0 Kudos
Message 10 of 11
(4,894 Views)