473,323 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

vb dot net com+ Component rerun

Hi,

I have created a com+ component with vb dot net
using jit activation and transactions

If i call it like this

x=createobject("mycomp")
x.dispose

it works fine

if i try it in a loop it then locks up.
i would like to run it this way. What do i need to do
x=createobject("mycomp")

do while not eof
x.execute

LOOP

tia

Stu
Nov 20 '05 #1
5 1596
* "Stuart Dee" <s.***@cognatus.com> scripsit:
I have created a com+ component with vb dot net
using jit activation and transactions

If i call it like this

x=createobject("mycomp")
x.dispose

it works fine

if i try it in a loop it then locks up.
i would like to run it this way. What do i need to do
x=createobject("mycomp")

do while not eof
x.execute

LOOP


That should work. Maybe there is a bug in the implementation of 'Execute'?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #2
Hi,

I dont thinkso as it works fine if i call it like this

do while not eof
x=createobject("mycomp")
x.execute
set x=null
LOOP


-----Original Message-----
* "Stuart Dee" <s.***@cognatus.com> scripsit:
I have created a com+ component with vb dot net
using jit activation and transactions

If i call it like this

x=createobject("mycomp")
x.dispose

it works fine

if i try it in a loop it then locks up.
i would like to run it this way. What do i need to do
x=createobject("mycomp")

do while not eof
x.execute

LOOP
That should work. Maybe there is a bug in the

implementation of 'Execute'?
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
.

Nov 20 '05 #3
Hi Stuart,

Can you modify your code as simple as possible and post in the newsgroup
for me to reproduce the problem?
do while not eof
x=createobject("mycomp")
x.execute
set x=null
LOOP
Do you call the component in the Vb6 or VB.NET?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--------------------Content-Class: urn:content-classes:message
From: <an*******@discussions.microsoft.com>
Sender: <an*******@discussions.microsoft.com>
References: <0e****************************@phx.gbl> <bp*************@ID-208219.news.uni-berlin.de>Subject: Re: vb dot net com+ Component rerun
Date: Thu, 13 Nov 2003 09:21:09 -0800
Lines: 46
Message-ID: <34****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcOqCodX9pTNbyYiQlixxvvU5oROBg==
Newsgroups: microsoft.public.dotnet.languages.vb
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:156554
NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi,
I dont thinkso as it works fine if i call it like this
do while not eof
x=createobject("mycomp")
x.execute
set x=null
LOOP

-----Original Message-----
* "Stuart Dee" <s.***@cognatus.com> scripsit:
I have created a com+ component with vb dot net
using jit activation and transactions

If i call it like this

x=createobject("mycomp")
x.dispose

it works fine

if i try it in a loop it then locks up.
i would like to run it this way. What do i need to do
x=createobject("mycomp")

do while not eof
x.execute

LOOP


That should work. Maybe there is a bug in the

implementation of 'Execute'?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
.


Nov 20 '05 #4
Currently the component is called from
vb script,dot net and will be also in access

Im more interested in wether it should work
my assembly uses strong names like the following and ive
included some code from the main program. Hopefully you
may spot something

Regards

Stu

Option Explicit On
Option Strict On
Imports System.Runtime.InteropServices
Imports System.EnterpriseServices

Imports System.Data
Imports System.Data.SqlClient
Imports CGCalc.Common
Imports CGCalc.CalcDataAccess

Namespace cgCalc
<Transaction(TransactionOption.Required)> _
Public Class CalcEngine
Inherits ServicedComponent

Private Shared s_count As Integer = 0
Private m_count As Integer
Private m_canBePooled As Boolean = True

Public Sub New()
MyBase.New()
m_count =
System.Threading.Interlocked.Increment(s_count)
End Sub

Protected Overrides Function canBePooled() As
Boolean
Return m_canBePooled
End Function

Protected Overrides Sub activate()
m_canBePooled = False
End Sub
Protected Overrides Sub deactivate()
m_canBePooled = True
End Sub

Public Sub reset()
End Sub
Public ReadOnly Property version() As String
Get
version = CgCalcConfiguration.CGTVersion
End Get
End Property
Public Property Calcmode() As Integer
Get
Calcmode = m_CalcMode
End Get

Set(ByVal Value As Integer)
If Value < 0 Or Value > 3 Then
Throw New Exception("Invalid Calc
mode: " & CStr(Value))
End If
m_CalcMode = Value
CgCalcConfiguration.glo.gCalcMode = Value

End Set

End Property

Public Property Client() As Integer
Get
Client = CInt(m_Client)
End Get
Set(ByVal Value As Integer)

If Not
CgCalcConfiguration.glo.gGlobalsLoaded Then
Throw New Exception("CGcalc has not
been initialised")
End If

objCalcDB.getClientType(m_CalcMode, _
Value)

m_Client = Value

End Set
End Property

Public Property asset(ByVal passet As Integer) As
Integer
Get
passet = CInt(m_Asset)
End Get

Set(ByVal Value As Integer)
Dim reccount As Long

If Not
CgCalcConfiguration.glo.gGlobalsLoaded Then
Throw New Exception("CGcalc has not
been initialised")
End If

'check asset exists
reccount = objCalcDB.AssetExistsCheck
(Value)

If reccount = 0 Then
Throw New Exception("Invalid Asset
Code: " & passet)
End If

m_Asset = Value

End Set
End Property
Public ReadOnly Property ErrorText() As String
Get
ErrorText = m_Error
End Get
End Property
Public ReadOnly Property MultPoss() As Boolean
Get
MultPoss = m_Multpos
End Get
End Property
Public Property MQuantity(ByVal Qty As Double) As
Double
Get
Dim TaxYear As Integer, LoadTable As
Boolean
Dim tcg() As CalcInfo

If Not
CgCalcConfiguration.glo.gGlobalsLoaded Then
Throw New Exception("CGcalc has not
been initialised")
End If

Call Check_Parms()

LoadTable = True

Call objModel.AcheiveRequiredTGainLoss
(m_Client, tcg, m_Asset, MDate, Price, _
m_Gain, m_ReturnGainLoss, GraphReqd, _
m_Qty, m_Multpos, m_ReturnCode,
AuditReqd, m_Error, LoadTable, TaxYear, m_CalcMode, 0)
MQuantity = m_Qty

If InStr(CgCalcConfiguration.glo.gErrText,
CgCalcConfiguration.gFAILEDUPDATETEXT) <> 0 Then
Throw New Exception
(CgCalcConfiguration.gFAILEDUPDATETEXT)
End If

End Get
Set(ByVal Value As Double)
m_Qty = CDec(Value)
End Set
End Property
Public Property MGain() As Decimal
Get

Dim TaxYear As Integer
Dim tcg() As CalcInfo
Dim LoadTable As Boolean, UpdateData As
Boolean, IncludeUnconfirmed As Boolean

If Not
CgCalcConfiguration.glo.gGlobalsLoaded Then
Throw New Exception("CGcalc has not
been initialised")
End If
Call Check_Parms()

LoadTable = True
UpdateData = True
IncludeUnconfirmed = False

Call objModel.ComputeGainLoss(m_Client,
tcg, m_Asset, Price, MDate, _
TaxYear, m_Qty, m_NetGL, m_LossApplied,
m_Taper, m_Gain, _
m_LossCF, m_Error, UpdateData,
LoadTable, IncludeUnconfirmed, _
AuditReqd, m_ReturnCode, m_CalcMode)

MGain = m_Gain

If InStr(CgCalcConfiguration.glo.gErrText,
CgCalcConfiguration.gFAILEDUPDATETEXT) <> 0 Then
Throw New Exception
(CgCalcConfiguration.gFAILEDUPDATETEXT)
End If

End Get
Set(ByVal Value As Decimal)
m_Gain = Value
End Set
End Property

Public ReadOnly Property ReturnGain() As Decimal
Get
ReturnGain = m_ReturnGainLoss
End Get
End Property

Private Sub Check_Parms()
Dim holdingsDR As SqlDataReader
Dim reccount As Long
Dim validated_asset() As Boolean
Dim MaxHldgs As Integer, AssetX As Integer,
maxtxns As Integer, X As Integer
Dim NullTxn As CGcalcTxnStructure

If m_Client = 0 Then
m_ReturnCode = 9
Throw New Exception("Client not
specified.")
End If

If m_CalcMode < 0 Or m_CalcMode > 3 Then
m_ReturnCode = 9
Throw New Exception("Calcmode incorrectly
specified: " & m_CalcMode)
End If

If m_CalcMode =
CgCalcConfiguration.WHAT_IF_CALC_MODE Then
If m_Asset = 0 Then
m_ReturnCode = 9
Throw New Exception("Asset not
specified.")
End If

'check client has a holding in the asset
to model
reccount = objCalcDB.clientAssetHldgExists
(m_Client, m_Asset)

If reccount = 0 Then
m_ReturnCode = 9
Throw New Exception("Client does not
have a holding in the asset.")
End If
End If

If m_CalcMode =
CgCalcConfiguration.WHAT_IF_CALC_MODE Then
'check date is >= current
If MDate < System.DateTime.Now Then
m_ReturnCode = 9
Throw New Exception("Modelling date
cannot be in the past.")
End If
End If

If m_CalcMode =
CgCalcConfiguration.MODEL_SLE_TXNS_MODE Or m_CalcMode =
CgCalcConfiguration.MODEL_PUR_TXNS_MODE Then

maxtxns = UBound(m_ModelTxns)

For X = 1 To maxtxns
If CInt(m_ModelTxns(X).InQty) = 0 Then
Exit For
End If
MaxHldgs = X
Next X

If MaxHldgs > 0 Then

ReDim validated_asset(MaxHldgs)

'validate all the holdings exist
holdingsDR =
objCalcDB.ClientHoldingList(m_Client)

Do While holdingsDR.Read
For AssetX = 1 To MaxHldgs
If CLng(holdingsDR.Item
("AssetID")) = m_ModelTxns(AssetX).AssetID Then
validated_asset(AssetX) =
True
End If
Next AssetX

Loop
End If

For AssetX = 1 To MaxHldgs

If Not validated_asset(AssetX) Then
m_ReturnCode = 9
Throw New Exception("Client does
not have a holding in the asset." & m_ModelTxns
(AssetX).AssetID)
End If
Next AssetX
End If
End Sub
<AutoComplete()> _
Public Function CalcCGT() As Integer

Dim reccount As Long
Dim tcg() As CalcInfo

m_ReturnCode = 0

If Not CgCalcConfiguration.glo.gGlobalsLoaded
Then
Throw New Exception("CGcalc has not been
initialised")
End If
Call Check_Parms()

objEvent.EventProcessor(m_Client, tcg,
m_CalcMode, m_Asset, 0, Price, _
True, True, False,
AuditReqd, m_ReturnCode)

CalcCGT = m_ReturnCode
If InStr(CgCalcConfiguration.glo.gErrText,
CgCalcConfiguration.gFAILEDUPDATETEXT) <> 0 Then
m_ReturnCode = 8
CalcCGT = 8
'Err.Raise 111 + gObjectError, ,
gFailedUpdateText
End If

Return CalcCGT
End Function
Public ReadOnly Property ReturnCode() As String
Get
ReturnCode = CStr(m_ReturnCode)
End Get
End Property

Public Sub InitialiseClass(ByVal PServer As
String, _
ByVal PDatabase As String, _
Optional ByVal PUser As String = "", _
Optional ByVal PPassword As String = "")
If Not CgCalcConfiguration.glo.gGlobalsLoaded
Then
ReDim CgCalcConfiguration.glo.gEELtxt(9)

Call load_globals(PServer, _
PDatabase, _
PUser, _
PPassword, _
m_Error)

End If

If m_Error <> "" Then
Throw New Exception(m_Error)
End If
End Sub
Public Function Execute(ByVal Action As String) As
String

'A generic function for future
methods/properties without
'inflicting painful version incompatability
issues.
'For use refer francesco balena's book
prog'ing vb6 pg850

Select Case Action

Case "CGCALC"

Execute = "test generic function"

Case "AutoGenerateAllDisposals"
'this function just sets the boolean
value to state that all
'modelled txns will be generated
automatically from the notionals.
'Ordinarily this would be a class
variable, but rolling out a new class is
'too painful...!
m_AutoGenerateAllDisposals = True
Execute = "Set
AutoGenerateAllDisposals to true."

End Select

Return Execute
End Function

Public Property ModelTxns() As CGcalcTxnType()
Get
ModelTxns = m_ModelTxns
End Get
Set(ByVal Value As CGcalcTxnType())
m_ModelTxns = Value
End Set
End Property

<AutoComplete()> _
Function ModelTxnSet() As Integer

Dim TaxYear As Integer
Dim tcg() As CalcInfo

If Not CgCalcConfiguration.glo.gGlobalsLoaded
Then
Throw New Exception("CGcalc has not been
initialised")
End If
Call Check_Parms()

Select Case m_CalcMode

Case
CgCalcConfiguration.MODEL_SLE_TXNS_MODE

Call objModel.ModelMultipleDisposals
(m_Client, tcg, m_ModelTxns, ModelTxnSortID, m_NetGL, _
m_LossApplied, m_Taper,
m_ReturnGainLoss, m_LossCF, m_Error, m_ReturnCode,
m_CalcMode, _
m_AutoGenerateAllDisposals)

Case
CgCalcConfiguration.MODEL_PUR_TXNS_MODE

Call objModel.ModelMultipleAcquisitions
(m_Client, tcg, m_ModelTxns, m_NetGL, _
m_LossApplied, m_Taper,
m_ReturnGainLoss, m_LossCF, m_Error, m_ReturnCode,
m_CalcMode)

End Select

ModelTxnSet = m_ReturnCode

MGain = m_Gain

If InStr(CgCalcConfiguration.glo.gErrText,
CgCalcConfiguration.gFAILEDUPDATETEXT) <> 0 Then
Throw New Exception
(CgCalcConfiguration.gFAILEDUPDATETEXT)
End If

Return ModelTxnSet
End Function
End Class
End Namespace
<Assembly: ApplicationActivation(ActivationOption.Server)>
<Assembly: AssemblyTitle("Calcxxxxx")>
<Assembly: ApplicationName("xxxxxx(Dot Net)")>
<Assembly: AssemblyDescription("Calculator Engine")>
<Assembly: AssemblyCompany("xxxxxx Financial Systems")>
<Assembly: AssemblyProduct("xxxx")>
<Assembly: AssemblyCopyright("2003")>
<Assembly: AssemblyTrademark("")>
<Assembly: CLSCompliant(True)>
<Assembly: AssemblyKeyFile("DotNetCalc.snk")>

'The following GUID is for the ID of the typelib if this
project is exposed to COM
<Assembly: Guid("84838924-1931-4C0A-BB23-D4E4BFABAD96")>

' Version information for an assembly consists of the
following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the
Build and Revision Numbers
' by using the '*' as shown below:

<Assembly: AssemblyVersion("1.0.*")>

-----Original Message-----
Hi Stuart,

Can you modify your code as simple as possible and post in the newsgroup for me to reproduce the problem?
do while not eof
x=createobject("mycomp")
x.execute
set x=null
LOOP
Do you call the component in the Vb6 or VB.NET?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and

confers no rights. --------------------
Content-Class: urn:content-classes:message
From: <an*******@discussions.microsoft.com>
Sender: <an*******@discussions.microsoft.com>
References: <0e****************************@phx.gbl>

<bp*************@ID-208219.news.uni-berlin.de>
Subject: Re: vb dot net com+ Component rerun
Date: Thu, 13 Nov 2003 09:21:09 -0800
Lines: 46
Message-ID: <34****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcOqCodX9pTNbyYiQlixxvvU5oROBg==
Newsgroups: microsoft.public.dotnet.languages.vb
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:156554NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Hi,
I dont thinkso as it works fine if i call it like this
do while not eof
x=createobject("mycomp")
x.execute
set x=null
LOOP

-----Original Message-----
* "Stuart Dee" <s.***@cognatus.com> scripsit:
I have created a com+ component with vb dot net
using jit activation and transactions

If i call it like this

x=createobject("mycomp")
x.dispose

it works fine

if i try it in a loop it then locks up.
i would like to run it this way. What do i need to do
x=createobject("mycomp")

do while not eof
x.execute

LOOP

That should work. Maybe there is a bug in the

implementation of 'Execute'?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
.


.

Nov 20 '05 #5
Hi ,

That seems to a complex project. Your project doesn't work on my machine. (
I can not compile it)
After I code review, I did not find anything special which will cause the
problem.
Based on my understanding, you call the COM+ component in one thread in a
loop.

Here is my demo test, you may have a look to see if this code works on you
machine.

Dim o
set o = CreateObject("BankComponent.Account")
Dim i
i = 0
While i < 10
msgbox o.sqrt(i)
i = i + 1
Wend

Imports System.EnterpriseServices
Imports System.Runtime.CompilerServices
Imports System.Reflection
Imports System.Runtime.InteropServices

Namespace BankComponent
<Transaction(TransactionOption.Required),
ClassInterface(ClassInterfaceType.AutoDual)> _
Public Class Account
Inherits ServicedComponent
Dim m_count As Integer
Shared s_count As Integer
Public Sub New()
MyBase.New()
m_count = System.Threading.Interlocked.Increment(s_count)
End Sub
<AutoComplete()> _
Public Function Sqrt(ByVal x As Integer) As Integer
Sqrt = x * x
' Updates the database; no need to call SetComplete.
' Calls SetComplete automatically if no exception is generated.
End Function
End Class
End Namespace

Since it seems a large project, for such big code review has beyond the
newsgroup support field.
For more detailed code review I suggest you call Microsoft Product Support
Services (PSS) for further help.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a simple COM DLL in .NET by using the COM class...
7
by: Richard Gutery | last post by:
I have written a COM component who's purpose is to allow a user to change his Windows (NT/AD) password via a web page. Now the component works fine when I run it in VB 6, but not via the web page....
0
by: Balamurukan | last post by:
Hi, when I place the Component (for Ex Grid ) created in Vb.NETwhich uses Latebinding in our C# Form is not getting Persisted when i rerun the Application After Closing it.The Grid is Removed...
26
by: Lasse Edsvik | last post by:
Hello I'm trying to build a simple COM+ app in vs.net using C# and i cant register it in component manager..... what more is needed than this: using System; using...
1
by: Feng | last post by:
Hi, I am currently experiencing a wired issue. Every time I start my my dev server machine to run my ASP.Net app, the IIS server is not functioning - I get page can not be displayed error and I...
4
by: Bill Nicholson - Cincinnati, OH | last post by:
This Access app is in Access 2000 format. It is a mature app that is running on machines all over the LAN. Today when I tried to put it on a new PC with a fresh copy of Win XP and Access 2003. XP...
63
by: socondc22 | last post by:
So i have a question on how i should start doing this... pretty new at c++ i have to ask the user for an integer, an operator, and then another integer to give an answer. But i also have to show...
3
by: socondc22 | last post by:
just wondering how to rerun my program after printing out the answer...
3
by: Saxx | last post by:
i have created a program that counts change for school but i am also wanting to add the ability fot the program to rerun on request and display an error message for negatitve numers, 0 or letters. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.