No Brain Problem!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Have a very simple problem that I'm having a tough time explaining/solving. The problem is that I get different results when I print "?" a variable when using Enterprise Services (ES) than when ES is not included. The code for the 3 classes is below:

Class #1 - STARBatchParms.vb
===================
This class simply contains the structure that I want to pass from my form to my class:

Public Structure BATCH_PARMS
Public lLowerLimit As Integer
End Structure


Class #2 - BatchSimulator
================
This is simply a Form with a Go button. The click event runs the following code to build/load the structure and pass it to the 3rd and final component.

Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGo.Click

Dim clsBatchParms As New STARBatchParms.BATCH_PARMS
clsBatchParms.lLowerLimit = 123456789
Dim x As New STCI.cExecCl
Try
x.Execute(clsBatchParms)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub

Class #3 - STCl
==========
The third and final class receives the parms as an input parameter. I then inspect the same parameter via 2 different techniques and get 2 different results:

Imports System.EnterpriseServices

Public Class cExecCl
Inherits ServicedComponent

Private mBatch_parms As STARBatchParms.BATCH_PARMS

Public Sub Execute(ByVal clsBatchParms As STARBatchParms.BATCH_PARMS)

mBatch_parms = clsBatchParms

'Place a break-point on the following line. to allow you to send the statement
'? mBatch_parms.lLowerLimit.ToString to the Immediate window.
'Returns a value different than the following statement gives to
'the OutPut Windows. What Gives???
Debug.WriteLine(mBatch_parms.lLowerLimit.ToString)

'Why didn't "?" and "Debug" produce same results?

Exit Sub

End Sub


Insult to Injury
=========
If "Inherits ServicedComponent" is removed from Class #3, everything works as expected in terms of "debug" and "?" producing the same results.

Any input will be greatly appreciated!!!
 
Hi Dave,

Very vague idea...when a class is inherited from ServicedComponent, its
methods' parameters are required to be COM-compatible. As long as, to the
best of my knowledge, custom structs can be used, this might involve issues.
Try to repost this question to the microsoft.public.dotnet.framework.interop
newsgroup or at least play with attributes applied to the STARBatchParms.vb
structure.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Dave said:
Have a very simple problem that I'm having a tough time
explaining/solving. The problem is that I get different results when I
print "?" a variable when using Enterprise Services (ES) than when ES is not
included. The code for the 3 classes is below:
Class #1 - STARBatchParms.vb
===================
This class simply contains the structure that I want to pass from my form to my class:

Public Structure BATCH_PARMS
Public lLowerLimit As Integer
End Structure


Class #2 - BatchSimulator
================
This is simply a Form with a Go button. The click event runs the
following code to build/load the structure and pass it to the 3rd and final
component.
Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdGo.Click
Dim clsBatchParms As New STARBatchParms.BATCH_PARMS
clsBatchParms.lLowerLimit = 123456789
Dim x As New STCI.cExecCl
Try
x.Execute(clsBatchParms)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub

Class #3 - STCl
==========
The third and final class receives the parms as an input parameter. I
then inspect the same parameter via 2 different techniques and get 2
different results:
Imports System.EnterpriseServices

Public Class cExecCl
Inherits ServicedComponent

Private mBatch_parms As STARBatchParms.BATCH_PARMS

Public Sub Execute(ByVal clsBatchParms As STARBatchParms.BATCH_PARMS)

mBatch_parms = clsBatchParms

'Place a break-point on the following line. to allow you to send the statement
'? mBatch_parms.lLowerLimit.ToString to the Immediate window.
'Returns a value different than the following statement gives to
'the OutPut Windows. What Gives???
Debug.WriteLine(mBatch_parms.lLowerLimit.ToString)

'Why didn't "?" and "Debug" produce same results?

Exit Sub

End Sub


Insult to Injury
=========
If "Inherits ServicedComponent" is removed from Class #3, everything works
as expected in terms of "debug" and "?" producing the same results.
 
Back
Top