[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Urgent :SN utility and .net distributed transaction

shabbir hussain bohra

8/23/2004 8:07:00 AM

I have written a vb.net component for automatic distributed transaction.
the code is as:
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.EnterpriseServices
<Transaction(transactionoption.required)> _
Public Class ShabTransmitDataComponent
Inherits Servicedcomponent

Private oCon As SqlConnection
Private oCom As SqlCommand
Private sTransmitIP, UID, PWD As String
Private sSqlQry As String
Private cls As New ClassLibrary.DBClass
Dim clsIntegrateData As New Transmit.clsIntegrateData ' added by shabbir 230804
#Region "Transmitting Files"
Public Function TransmitFiles(ByVal filepath As String, ByVal oDtTransmit As DataTable, ByVal iStation As Int16, ByRef TransmitErrorDetails As String) As Int32 'modified by shabbir 110804
Dim sw As System.IO.StreamWriter
Dim logfile As System.IO.File
Dim reccount As Int32 = 0
Dim i, TotalRec As Int32
Dim bRecInsert As Boolean = False
Dim arrText As New ArrayList
Dim tablearray As New ArrayList
Dim iCounter As Int32 = 0
Dim TableName As String
Dim loopCounter As Boolean = False
TotalRec = 0
If logfile.Exists(filepath) = True Then
logfile.Delete(filepath)
End If
Try
sw = logfile.CreateText(filepath)
oCon = New SqlConnection
oCon = cls.OpenConnection()
sTransmitIP = "[" & sTransmitIP & "]"
sw.WriteLine("Transmission start to host at : " & Now())
While loopCounter = False
Try
If i < oDtTransmit.Rows.Count Then
For i = iCounter To oDtTransmit.Rows.Count - 1
If Convert.ToInt32(oDtTransmit.Rows(i)(i)) > 0 Then
TableName = oDtTransmit.Columns(i).ColumnName
GetQuery(TableName, iStation)
oCom = New SqlCommand(sSqlQry, oCon)
oCom.CommandTimeout = 600
reccount = oCom.ExecuteNonQuery()
oCom.Dispose()
TotalRec = TotalRec + reccount
If reccount > 0 Then
UpdateData(TableName, TransmitErrorDetails) 'commented by shab 150804
sw.WriteLine("Transmitted " & Convert.ToString(reccount) & " " & oDtTransmit.Columns(i).ColumnName & " to host")
arrText.Add("Transmitted " & Convert.ToString(reccount) & " " & TableName & " to host")
reccount = 0
End If
bRecInsert = True
End If
Next
End If
If bRecInsert = True Then
bRecInsert = False
sSqlQry = sTransmitIP & ".AGS_HOST.DBO.AGS_TransmitToHost"
oCom = New SqlCommand(sSqlQry, oCon)
oCom.CommandType = CommandType.StoredProcedure
oCom.CommandTimeout = 600
oCom.Parameters.Add("@OriginStid", SqlDbType.SmallInt).Value = iStation
oCom.Parameters.Add("@Return", SqlDbType.Int).Direction = ParameterDirection.ReturnValue
Dim j As Int32 = Convert.ToInt32(oCom.Parameters("@Return").Value)
j = oCom.ExecuteNonQuery()
End If
If arrText.Count > 0 Then
For i = 0 To arrText.Count - 1
sw.WriteLine(Convert.ToString(arrText(i)))
Next
End If
sw.WriteLine("Transmission end to host at : " & Now())
sw.Close()
sw = Nothing
loopCounter = True
TransmitFiles = TotalRec
contextutil.setcomplete()
Catch ex As SqlException
TransmitErrorDetails = TransmitErrorDetails & Chr(13) & "CLS-Transmit-Data Transmission error Source: " & ex.Source & Chr(13) & "CLS-Transmit-Data Transmission error Message: " & ex.Message 'Added by shabbir 110804
Dim Errsw As System.IO.StreamWriter
Dim Errfile As System.IO.File
Dim Errfilepath As String = filepath.Substring(0, filepath.Length - 12) & "/TransErrLog.txt"
If Errfile.Exists(Errfilepath) = True Then
Errsw = Errfile.AppendText(Errfilepath)
Else
Errsw = Errfile.CreateText(Errfilepath)
End If
Errsw.WriteLine("Date : " & Now() & "Source : " & ex.Source & " Message : " & ex.Message)
Errsw.Close()
Errsw = Nothing
Errfile = Nothing
If ex.Number = 17 Then
TransmitErrorDetails = TransmitErrorDetails & Chr(13) & "CLS-Transmit-Data Transmission error Source: " & ex.Source & Chr(13) & "CLS-Transmit-Data Transmission error Message: " & ex.Message 'Added by shabbir 110804
Throw ex
Exit While
Else
'TransmitErrorDetails = TransmitErrorDetails & Chr(13) & "CLS-Transmit-Data Transmission error Source: " & ex.Source & Chr(13) & "CLS-Transmit-Data Transmission error Message: " & ex.Message 'Added by shabbir 110804
arrText.Add("Failed to transmit data to host")
iCounter = i + 1
End If
'Added by shabbir 110804
Try
contextutil.setabort()
loopCounter = True
sw.WriteLine("Error in Transmission - Disconnected from host : " & Now())
sw.Close()
sw = Nothing
Exit Function
Catch ex1 As Exception
TransmitErrorDetails = TransmitErrorDetails & Chr(13) & "CLS-Transmit-Data Transmission Rollback error Source: " & ex1.Source & Chr(13) & "CLS-Transmit-Data Transmission Rollback error Message: " & ex1.Message
End Try
'End-Added by shabbir 110804
End Try
End While
Catch ex As Exception
'Added by shabbir 110804
TransmitErrorDetails = TransmitErrorDetails & Chr(13) & "CLS-Transmit-Data Transmission error Source: " & ex.Source & Chr(13) & "CLS-Transmit-Data Transmission error Message: " & ex.Message 'Added by shabbir 110804
sw.WriteLine("Transmission end to host at : " & Now())
sw.Close()
sw = Nothing
'End-Added by shabbir 110804
End Try
End Function
#End Region
I have created a SNK file for this using sn.exe -k shabtransmitdata.snk
i copied this snk file to the project root and added it to the project the following line in the assembly file:
<Assembly: AssemblyKeyFile("D:\GulfSoft Default Screens\GulfSoft\shabtransmitdata.snk")>

now when i am building the project it is giving me this error:
Unable to emit assembly: Referenced assembly 'Station' does not have a strong name

Can anybody give clues , code or links to clear my concepts or guide me where and what i am doing wrong?

your help is highly appreciated.

Regrds,
Shabbir


___
Newsgroups brought to you courtesy of www.dotnetjohn.com
2 Answers

Sam Santiago

8/23/2004 4:19:00 PM

0

Check out these links:

DOC: Serviced Components Require Referenced Components to Be Strong-named
http://support.microsoft.com/default.aspx?scid=kb;en...

and

Signing an Assembly
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconassigningassemblystro...

Perhaps your are using the wrong attribute name:

<Assembly: AssemblyKeyFile("D:\GulfSoft Default
Screens\GulfSoft\shabtransmitdata.snk")>

You have a space after the colon and a different attribute name than the
example in the link:

<Assembly:AssemblyKeyFileAttribute("sgKey.snk")>

Thanks,

Sam
--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"shabbir hussain bohra" <shabbir.hussain@alghandisolutions.com> wrote in
message news:OpegwgOiEHA.1384@TK2MSFTNGP10.phx.gbl...
> I have written a vb.net component for automatic distributed transaction.
> the code is as:
> Imports System.Data.SqlClient
> Imports System.Configuration
> Imports System.EnterpriseServices
> <Transaction(transactionoption.required)> _
> Public Class ShabTransmitDataComponent
> Inherits Servicedcomponent
>
> Private oCon As SqlConnection
> Private oCom As SqlCommand
> Private sTransmitIP, UID, PWD As String
> Private sSqlQry As String
> Private cls As New ClassLibrary.DBClass
> Dim clsIntegrateData As New Transmit.clsIntegrateData ' added by
shabbir 230804
> #Region "Transmitting Files"
> Public Function TransmitFiles(ByVal filepath As String, ByVal
oDtTransmit As DataTable, ByVal iStation As Int16, ByRef
TransmitErrorDetails As String) As Int32 'modified by shabbir 110804
> Dim sw As System.IO.StreamWriter
> Dim logfile As System.IO.File
> Dim reccount As Int32 = 0
> Dim i, TotalRec As Int32
> Dim bRecInsert As Boolean = False
> Dim arrText As New ArrayList
> Dim tablearray As New ArrayList
> Dim iCounter As Int32 = 0
> Dim TableName As String
> Dim loopCounter As Boolean = False
> TotalRec = 0
> If logfile.Exists(filepath) = True Then
> logfile.Delete(filepath)
> End If
> Try
> sw = logfile.CreateText(filepath)
> oCon = New SqlConnection
> oCon = cls.OpenConnection()
> sTransmitIP = "[" & sTransmitIP & "]"
> sw.WriteLine("Transmission start to host at : " & Now())
> While loopCounter = False
> Try
> If i < oDtTransmit.Rows.Count Then
> For i = iCounter To oDtTransmit.Rows.Count - 1
> If Convert.ToInt32(oDtTransmit.Rows(i)(i)) > 0
Then
> TableName =
oDtTransmit.Columns(i).ColumnName
> GetQuery(TableName, iStation)
> oCom = New SqlCommand(sSqlQry, oCon)
> oCom.CommandTimeout = 600
> reccount = oCom.ExecuteNonQuery()
> oCom.Dispose()
> TotalRec = TotalRec + reccount
> If reccount > 0 Then
> UpdateData(TableName,
TransmitErrorDetails) 'commented by shab 150804
> sw.WriteLine("Transmitted " &
Convert.ToString(reccount) & " " & oDtTransmit.Columns(i).ColumnName & " to
host")
> arrText.Add("Transmitted " &
Convert.ToString(reccount) & " " & TableName & " to host")
> reccount = 0
> End If
> bRecInsert = True
> End If
> Next
> End If
> If bRecInsert = True Then
> bRecInsert = False
> sSqlQry = sTransmitIP &
".AGS_HOST.DBO.AGS_TransmitToHost"
> oCom = New SqlCommand(sSqlQry, oCon)
> oCom.CommandType = CommandType.StoredProcedure
> oCom.CommandTimeout = 600
> oCom.Parameters.Add("@OriginStid",
SqlDbType.SmallInt).Value = iStation
> oCom.Parameters.Add("@Return",
SqlDbType.Int).Direction = ParameterDirection.ReturnValue
> Dim j As Int32 =
Convert.ToInt32(oCom.Parameters("@Return").Value)
> j = oCom.ExecuteNonQuery()
> End If
> If arrText.Count > 0 Then
> For i = 0 To arrText.Count - 1
> sw.WriteLine(Convert.ToString(arrText(i)))
> Next
> End If
> sw.WriteLine("Transmission end to host at : " & Now())
> sw.Close()
> sw = Nothing
> loopCounter = True
> TransmitFiles = TotalRec
> contextutil.setcomplete()
> Catch ex As SqlException
> TransmitErrorDetails = TransmitErrorDetails & Chr(13)
& "CLS-Transmit-Data Transmission error Source: " & ex.Source & Chr(13) &
"CLS-Transmit-Data Transmission error Message: " & ex.Message 'Added by
shabbir 110804
> Dim Errsw As System.IO.StreamWriter
> Dim Errfile As System.IO.File
> Dim Errfilepath As String = filepath.Substring(0,
filepath.Length - 12) & "/TransErrLog.txt"
> If Errfile.Exists(Errfilepath) = True Then
> Errsw = Errfile.AppendText(Errfilepath)
> Else
> Errsw = Errfile.CreateText(Errfilepath)
> End If
> Errsw.WriteLine("Date : " & Now() & "Source : " &
ex.Source & " Message : " & ex.Message)
> Errsw.Close()
> Errsw = Nothing
> Errfile = Nothing
> If ex.Number = 17 Then
> TransmitErrorDetails = TransmitErrorDetails &
Chr(13) & "CLS-Transmit-Data Transmission error Source: " & ex.Source &
Chr(13) & "CLS-Transmit-Data Transmission error Message: " & ex.Message
'Added by shabbir 110804
> Throw ex
> Exit While
> Else
> 'TransmitErrorDetails = TransmitErrorDetails &
Chr(13) & "CLS-Transmit-Data Transmission error Source: " & ex.Source &
Chr(13) & "CLS-Transmit-Data Transmission error Message: " & ex.Message
'Added by shabbir 110804
> arrText.Add("Failed to transmit data to host")
> iCounter = i + 1
> End If
> 'Added by shabbir 110804
> Try
> contextutil.setabort()
> loopCounter = True
> sw.WriteLine("Error in Transmission - Disconnected
from host : " & Now())
> sw.Close()
> sw = Nothing
> Exit Function
> Catch ex1 As Exception
> TransmitErrorDetails = TransmitErrorDetails &
Chr(13) & "CLS-Transmit-Data Transmission Rollback error Source: " &
ex1.Source & Chr(13) & "CLS-Transmit-Data Transmission Rollback error
Message: " & ex1.Message
> End Try
> 'End-Added by shabbir 110804
> End Try
> End While
> Catch ex As Exception
> 'Added by shabbir 110804
> TransmitErrorDetails = TransmitErrorDetails & Chr(13) &
"CLS-Transmit-Data Transmission error Source: " & ex.Source & Chr(13) &
"CLS-Transmit-Data Transmission error Message: " & ex.Message 'Added by
shabbir 110804
> sw.WriteLine("Transmission end to host at : " & Now())
> sw.Close()
> sw = Nothing
> 'End-Added by shabbir 110804
> End Try
> End Function
> #End Region
> I have created a SNK file for this using sn.exe -k shabtransmitdata.snk
> i copied this snk file to the project root and added it to the project the
following line in the assembly file:
> <Assembly: AssemblyKeyFile("D:\GulfSoft Default
Screens\GulfSoft\shabtransmitdata.snk")>
>
> now when i am building the project it is giving me this error:
> Unable to emit assembly: Referenced assembly 'Station' does not have a
strong name
>
> Can anybody give clues , code or links to clear my concepts or guide me
where and what i am doing wrong?
>
> your help is highly appreciated.
>
> Regrds,
> Shabbir
>
>
> ___
> Newsgroups brought to you courtesy of www.dotnetjohn.com


Ken Kolda

8/23/2004 7:27:00 PM

0

Every assembly referenced by a stronly-named assembly must also be
strongly-named. It sounds like you are referencing an assembly named
"Station" which isn't signed.

Ken


"shabbir hussain bohra" <shabbir.hussain@alghandisolutions.com> wrote in
message news:OpegwgOiEHA.1384@TK2MSFTNGP10.phx.gbl...
> I have written a vb.net component for automatic distributed transaction.
> the code is as:
> Imports System.Data.SqlClient
> Imports System.Configuration
> Imports System.EnterpriseServices
> <Transaction(transactionoption.required)> _
> Public Class ShabTransmitDataComponent
> Inherits Servicedcomponent
>
> Private oCon As SqlConnection
> Private oCom As SqlCommand
> Private sTransmitIP, UID, PWD As String
> Private sSqlQry As String
> Private cls As New ClassLibrary.DBClass
> Dim clsIntegrateData As New Transmit.clsIntegrateData ' added by
shabbir 230804
> #Region "Transmitting Files"
> Public Function TransmitFiles(ByVal filepath As String, ByVal
oDtTransmit As DataTable, ByVal iStation As Int16, ByRef
TransmitErrorDetails As String) As Int32 'modified by shabbir 110804
> Dim sw As System.IO.StreamWriter
> Dim logfile As System.IO.File
> Dim reccount As Int32 = 0
> Dim i, TotalRec As Int32
> Dim bRecInsert As Boolean = False
> Dim arrText As New ArrayList
> Dim tablearray As New ArrayList
> Dim iCounter As Int32 = 0
> Dim TableName As String
> Dim loopCounter As Boolean = False
> TotalRec = 0
> If logfile.Exists(filepath) = True Then
> logfile.Delete(filepath)
> End If
> Try
> sw = logfile.CreateText(filepath)
> oCon = New SqlConnection
> oCon = cls.OpenConnection()
> sTransmitIP = "[" & sTransmitIP & "]"
> sw.WriteLine("Transmission start to host at : " & Now())
> While loopCounter = False
> Try
> If i < oDtTransmit.Rows.Count Then
> For i = iCounter To oDtTransmit.Rows.Count - 1
> If Convert.ToInt32(oDtTransmit.Rows(i)(i)) > 0
Then
> TableName =
oDtTransmit.Columns(i).ColumnName
> GetQuery(TableName, iStation)
> oCom = New SqlCommand(sSqlQry, oCon)
> oCom.CommandTimeout = 600
> reccount = oCom.ExecuteNonQuery()
> oCom.Dispose()
> TotalRec = TotalRec + reccount
> If reccount > 0 Then
> UpdateData(TableName,
TransmitErrorDetails) 'commented by shab 150804
> sw.WriteLine("Transmitted " &
Convert.ToString(reccount) & " " & oDtTransmit.Columns(i).ColumnName & " to
host")
> arrText.Add("Transmitted " &
Convert.ToString(reccount) & " " & TableName & " to host")
> reccount = 0
> End If
> bRecInsert = True
> End If
> Next
> End If
> If bRecInsert = True Then
> bRecInsert = False
> sSqlQry = sTransmitIP &
".AGS_HOST.DBO.AGS_TransmitToHost"
> oCom = New SqlCommand(sSqlQry, oCon)
> oCom.CommandType = CommandType.StoredProcedure
> oCom.CommandTimeout = 600
> oCom.Parameters.Add("@OriginStid",
SqlDbType.SmallInt).Value = iStation
> oCom.Parameters.Add("@Return",
SqlDbType.Int).Direction = ParameterDirection.ReturnValue
> Dim j As Int32 =
Convert.ToInt32(oCom.Parameters("@Return").Value)
> j = oCom.ExecuteNonQuery()
> End If
> If arrText.Count > 0 Then
> For i = 0 To arrText.Count - 1
> sw.WriteLine(Convert.ToString(arrText(i)))
> Next
> End If
> sw.WriteLine("Transmission end to host at : " & Now())
> sw.Close()
> sw = Nothing
> loopCounter = True
> TransmitFiles = TotalRec
> contextutil.setcomplete()
> Catch ex As SqlException
> TransmitErrorDetails = TransmitErrorDetails & Chr(13)
& "CLS-Transmit-Data Transmission error Source: " & ex.Source & Chr(13) &
"CLS-Transmit-Data Transmission error Message: " & ex.Message 'Added by
shabbir 110804
> Dim Errsw As System.IO.StreamWriter
> Dim Errfile As System.IO.File
> Dim Errfilepath As String = filepath.Substring(0,
filepath.Length - 12) & "/TransErrLog.txt"
> If Errfile.Exists(Errfilepath) = True Then
> Errsw = Errfile.AppendText(Errfilepath)
> Else
> Errsw = Errfile.CreateText(Errfilepath)
> End If
> Errsw.WriteLine("Date : " & Now() & "Source : " &
ex.Source & " Message : " & ex.Message)
> Errsw.Close()
> Errsw = Nothing
> Errfile = Nothing
> If ex.Number = 17 Then
> TransmitErrorDetails = TransmitErrorDetails &
Chr(13) & "CLS-Transmit-Data Transmission error Source: " & ex.Source &
Chr(13) & "CLS-Transmit-Data Transmission error Message: " & ex.Message
'Added by shabbir 110804
> Throw ex
> Exit While
> Else
> 'TransmitErrorDetails = TransmitErrorDetails &
Chr(13) & "CLS-Transmit-Data Transmission error Source: " & ex.Source &
Chr(13) & "CLS-Transmit-Data Transmission error Message: " & ex.Message
'Added by shabbir 110804
> arrText.Add("Failed to transmit data to host")
> iCounter = i + 1
> End If
> 'Added by shabbir 110804
> Try
> contextutil.setabort()
> loopCounter = True
> sw.WriteLine("Error in Transmission - Disconnected
from host : " & Now())
> sw.Close()
> sw = Nothing
> Exit Function
> Catch ex1 As Exception
> TransmitErrorDetails = TransmitErrorDetails &
Chr(13) & "CLS-Transmit-Data Transmission Rollback error Source: " &
ex1.Source & Chr(13) & "CLS-Transmit-Data Transmission Rollback error
Message: " & ex1.Message
> End Try
> 'End-Added by shabbir 110804
> End Try
> End While
> Catch ex As Exception
> 'Added by shabbir 110804
> TransmitErrorDetails = TransmitErrorDetails & Chr(13) &
"CLS-Transmit-Data Transmission error Source: " & ex.Source & Chr(13) &
"CLS-Transmit-Data Transmission error Message: " & ex.Message 'Added by
shabbir 110804
> sw.WriteLine("Transmission end to host at : " & Now())
> sw.Close()
> sw = Nothing
> 'End-Added by shabbir 110804
> End Try
> End Function
> #End Region
> I have created a SNK file for this using sn.exe -k shabtransmitdata.snk
> i copied this snk file to the project root and added it to the project the
following line in the assembly file:
> <Assembly: AssemblyKeyFile("D:\GulfSoft Default
Screens\GulfSoft\shabtransmitdata.snk")>
>
> now when i am building the project it is giving me this error:
> Unable to emit assembly: Referenced assembly 'Station' does not have a
strong name
>
> Can anybody give clues , code or links to clear my concepts or guide me
where and what i am doing wrong?
>
> your help is highly appreciated.
>
> Regrds,
> Shabbir
>
>
> ___
> Newsgroups brought to you courtesy of www.dotnetjohn.com