473,386 Members | 1,733 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,386 software developers and data experts.

Finally block causing exception to throw twice with CryptoStream?

TC
Hey All,

I posted this to the Crypto users group and forgot to add the VB.Net users
group. I apologize for any confusion.

I have been testing a try / catch / finally block and purposely raising
exceptions and I've noticed that if an exception of "Length of the data to
decrypt is invalid." is raised with the CryptoStream object, later this
exception will get raised a second time and thrown to the caller when trying
to close the stream in a Finally block.

For example:

Try
' Do tasks that cause CryptoStream to throw invalid length while
decrypting

Catch ex as CryptographicException
' Handle exception here
Finally
If Not MemStream is Nothing then
' No 2nd exception thrown here
MemStream.Close()
End If

If Not CrypStream is Nothing then
' Exception thrown a 2nd time
CrypStream.Close()
End If
Has anyone else experienced the above?

If so, how to address the problem or is this a bug?


Jun 27 '08 #1
9 1935
On May 18, 7:36 pm, "TC" <getmyemai...@yahoo.comwrote:
Hey All,

I posted this to the Crypto users group and forgot to add the VB.Net users
group. I apologize for any confusion.

I have been testing a try / catch / finally block and purposely raising
exceptions and I've noticed that if an exception of "Length of the data to
decrypt is invalid." is raised with the CryptoStream object, later this
exception will get raised a second time and thrown to the caller when trying
to close the stream in a Finally block.

For example:

Try
' Do tasks that cause CryptoStream to throw invalid length while
decrypting

Catch ex as CryptographicException
' Handle exception here
Finally
If Not MemStream is Nothing then
' No 2nd exception thrown here
MemStream.Close()
End If

If Not CrypStream is Nothing then
' Exception thrown a 2nd time
CrypStream.Close()
End If

Has anyone else experienced the above?

If so, how to address the problem or is this a bug?
TC,
Do you experience the same problem when you use "Using-End Using"
statement instead of Try-Catch for CryptoStream object?

Thanks,

Onur Güzel
Jun 27 '08 #2
TC
Hey Onur,

So you would recommend something like the following:

MyFunction(ByVal encryptString as String) as String
Try
Using(MyCryptoStream)
' Do Crypto tasks
return MyEncryptedString
End Using
Catch ex as CryptographicException
HandleCryptoException ex
Catch ex as Exception
HandleException(ex)
return Nothing
Finally
If Not MyMemoryStream Is Nothing Then
MyMemoryStream.Close
End If
' Do not close CryptoStream here as it causes duplicitous
exception
' The 'Using' block will dispose of any CryptoStream resources
End Function

The above does not cause the duplicitous exception to be thrown.

Thanks,

Todd
"kimiraikkonen" <ki*************@gmail.comwrote in message
news:e7**********************************@a23g2000 hsc.googlegroups.com...
On May 18, 7:36 pm, "TC" <getmyemai...@yahoo.comwrote:
Hey All,

I posted this to the Crypto users group and forgot to add the VB.Net users
group. I apologize for any confusion.

I have been testing a try / catch / finally block and purposely raising
exceptions and I've noticed that if an exception of "Length of the data to
decrypt is invalid." is raised with the CryptoStream object, later this
exception will get raised a second time and thrown to the caller when
trying
to close the stream in a Finally block.

For example:

Try
' Do tasks that cause CryptoStream to throw invalid length while
decrypting

Catch ex as CryptographicException
' Handle exception here
Finally
If Not MemStream is Nothing then
' No 2nd exception thrown here
MemStream.Close()
End If

If Not CrypStream is Nothing then
' Exception thrown a 2nd time
CrypStream.Close()
End If

Has anyone else experienced the above?

If so, how to address the problem or is this a bug?
TC,
Do you experience the same problem when you use "Using-End Using"
statement instead of Try-Catch for CryptoStream object?

Thanks,

Onur Güzel
Jun 27 '08 #3
On May 19, 1:10*pm, "TC" <getmyemai...@yahoo.comwrote:
Hey Onur,

* * So you would recommend something like the following:

* * MyFunction(ByVal encryptString as String) as String
* * * * Try
* * * * * * Using(MyCryptoStream)
* * * * * * * * ' Do Crypto tasks
* * * * * * * * return MyEncryptedString
* * * * * * End Using
* * * * Catch ex as CryptographicException
* * * * * * HandleCryptoException ex
* * * * Catch ex as Exception
* * * * * * HandleException(ex)
* * * * * * return Nothing
* * * * Finally
* * * * * * If Not MyMemoryStream Is Nothing Then
* * * * * * * * MyMemoryStream.Close
* * * * * * End If
* * * * * * ' Do not close CryptoStream here as it causes duplicitous
exception
* * * * * * ' The 'Using' block will dispose of any CryptoStream resources
* * End Function

The above does not cause the duplicitous exception to be thrown.

Thanks,

Todd

"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message

news:e7**********************************@a23g2000 hsc.googlegroups.com...
On May 18, 7:36 pm, "TC" <getmyemai...@yahoo.comwrote:


Hey All,
I posted this to the Crypto users group and forgot to add the VB.Net users
group. *I apologize for any confusion.
I have been testing a try / catch / finally block and purposely raising
exceptions and I've noticed that if an exception of "Length of the data to
decrypt is invalid." is raised with the CryptoStream object, later this
exception will get raised a second time and thrown to the caller when
trying
to close the stream in a Finally block.
For example:
Try
* * *' Do tasks that cause CryptoStream to throw invalid length while
decrypting
Catch ex as CryptographicException
* * ' Handle exception here
Finally
* * If Not MemStream is Nothing then
* * * * ' No 2nd exception thrown here
* * * * MemStream.Close()
* * End If
* * If Not CrypStream is Nothing then
* * * * ' Exception thrown a 2nd time
* * * * CrypStream.Close()
* * End If
Has anyone else experienced the above?
If so, how to address the problem or is this a bug?

TC,
Do you experience the same problem when you use "Using-End Using"
statement instead of Try-Catch for CryptoStream object?

Thanks,

Onur Güzel- Hide quoted text -

- Show quoted text -
Hi,
If it solves your problem, it's OK, however you can also try to put
try-catch inside Using-End Using without "Finally" because "Using-End
Using" does all the disposal operation:
MyFunction(ByVal encryptString as String) as String

Using(MyCryptoStream)
Try
' Do Crypto tasks
return MyEncryptedString

Catch ex as CryptographicException
HandleCryptoException ex
' The 'Using' block will dispose of any CryptoStream
resources
End Using
End Function
Thanks,

Onur Güzel

Jun 27 '08 #4
TC
Ahhh... right... got it!

Thanks

"kimiraikkonen" <ki*************@gmail.comwrote in message
news:72**********************************@r66g2000 hsg.googlegroups.com...
On May 19, 1:10 pm, "TC" <getmyemai...@yahoo.comwrote:
Hey Onur,

So you would recommend something like the following:

MyFunction(ByVal encryptString as String) as String
Try
Using(MyCryptoStream)
' Do Crypto tasks
return MyEncryptedString
End Using
Catch ex as CryptographicException
HandleCryptoException ex
Catch ex as Exception
HandleException(ex)
return Nothing
Finally
If Not MyMemoryStream Is Nothing Then
MyMemoryStream.Close
End If
' Do not close CryptoStream here as it causes duplicitous
exception
' The 'Using' block will dispose of any CryptoStream resources
End Function

The above does not cause the duplicitous exception to be thrown.

Thanks,

Todd

"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message

news:e7**********************************@a23g2000 hsc.googlegroups.com...
On May 18, 7:36 pm, "TC" <getmyemai...@yahoo.comwrote:


Hey All,
I posted this to the Crypto users group and forgot to add the VB.Net
users
group. I apologize for any confusion.
I have been testing a try / catch / finally block and purposely raising
exceptions and I've noticed that if an exception of "Length of the data
to
decrypt is invalid." is raised with the CryptoStream object, later this
exception will get raised a second time and thrown to the caller when
trying
to close the stream in a Finally block.
For example:
Try
' Do tasks that cause CryptoStream to throw invalid length while
decrypting
Catch ex as CryptographicException
' Handle exception here
Finally
If Not MemStream is Nothing then
' No 2nd exception thrown here
MemStream.Close()
End If
If Not CrypStream is Nothing then
' Exception thrown a 2nd time
CrypStream.Close()
End If
Has anyone else experienced the above?
If so, how to address the problem or is this a bug?

TC,
Do you experience the same problem when you use "Using-End Using"
statement instead of Try-Catch for CryptoStream object?

Thanks,

Onur Güzel- Hide quoted text -

- Show quoted text -
Hi,
If it solves your problem, it's OK, however you can also try to put
try-catch inside Using-End Using without "Finally" because "Using-End
Using" does all the disposal operation:
MyFunction(ByVal encryptString as String) as String

Using(MyCryptoStream)
Try
' Do Crypto tasks
return MyEncryptedString

Catch ex as CryptographicException
HandleCryptoException ex
' The 'Using' block will dispose of any CryptoStream
resources
End Using
End Function
Thanks,

Onur Güzel
Jun 27 '08 #5
TC
Hey Onur,

Just to be clear, even though the 'Using' block is for the CryptoStream, it
will also dispose of the MemoryStream resources as well because it is within
that block (i.e. the 'Using' block not only applies to the IDisposable
interface of its calling object which, in this case, is the CryptoStream but
also the IDisposable interfaces available to objects within the block as
well)?

Thanks,

TC

"kimiraikkonen" <ki*************@gmail.comwrote in message
news:72**********************************@r66g2000 hsg.googlegroups.com...
On May 19, 1:10 pm, "TC" <getmyemai...@yahoo.comwrote:
Hey Onur,

So you would recommend something like the following:

MyFunction(ByVal encryptString as String) as String
Try
Using(MyCryptoStream)
' Do Crypto tasks
return MyEncryptedString
End Using
Catch ex as CryptographicException
HandleCryptoException ex
Catch ex as Exception
HandleException(ex)
return Nothing
Finally
If Not MyMemoryStream Is Nothing Then
MyMemoryStream.Close
End If
' Do not close CryptoStream here as it causes duplicitous
exception
' The 'Using' block will dispose of any CryptoStream resources
End Function

The above does not cause the duplicitous exception to be thrown.

Thanks,

Todd

"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message

news:e7**********************************@a23g2000 hsc.googlegroups.com...
On May 18, 7:36 pm, "TC" <getmyemai...@yahoo.comwrote:


Hey All,
I posted this to the Crypto users group and forgot to add the VB.Net
users
group. I apologize for any confusion.
I have been testing a try / catch / finally block and purposely raising
exceptions and I've noticed that if an exception of "Length of the data
to
decrypt is invalid." is raised with the CryptoStream object, later this
exception will get raised a second time and thrown to the caller when
trying
to close the stream in a Finally block.
For example:
Try
' Do tasks that cause CryptoStream to throw invalid length while
decrypting
Catch ex as CryptographicException
' Handle exception here
Finally
If Not MemStream is Nothing then
' No 2nd exception thrown here
MemStream.Close()
End If
If Not CrypStream is Nothing then
' Exception thrown a 2nd time
CrypStream.Close()
End If
Has anyone else experienced the above?
If so, how to address the problem or is this a bug?

TC,
Do you experience the same problem when you use "Using-End Using"
statement instead of Try-Catch for CryptoStream object?

Thanks,

Onur Güzel- Hide quoted text -

- Show quoted text -
Hi,
If it solves your problem, it's OK, however you can also try to put
try-catch inside Using-End Using without "Finally" because "Using-End
Using" does all the disposal operation:
MyFunction(ByVal encryptString as String) as String

Using(MyCryptoStream)
Try
' Do Crypto tasks
return MyEncryptedString

Catch ex as CryptographicException
HandleCryptoException ex
' The 'Using' block will dispose of any CryptoStream
resources
End Using
End Function
Thanks,

Onur Güzel
Jun 27 '08 #6
TC
Hey Onur,

Perhaps better said, in C#, one can do something like the following:

Using (object1, object2, object 3)
// Perform tasks
End Using

Is there a syntax for something similar in VB.Net or does one have to nest
the 'Using' statements like this:

Using (object1)
Using(object2)
// Perform tasks
End Using
End Using

Thanks,

TC

"kimiraikkonen" <ki*************@gmail.comwrote in message
news:72**********************************@r66g2000 hsg.googlegroups.com...
On May 19, 1:10 pm, "TC" <getmyemai...@yahoo.comwrote:
Hey Onur,

So you would recommend something like the following:

MyFunction(ByVal encryptString as String) as String
Try
Using(MyCryptoStream)
' Do Crypto tasks
return MyEncryptedString
End Using
Catch ex as CryptographicException
HandleCryptoException ex
Catch ex as Exception
HandleException(ex)
return Nothing
Finally
If Not MyMemoryStream Is Nothing Then
MyMemoryStream.Close
End If
' Do not close CryptoStream here as it causes duplicitous
exception
' The 'Using' block will dispose of any CryptoStream resources
End Function

The above does not cause the duplicitous exception to be thrown.

Thanks,

Todd

"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message

news:e7**********************************@a23g2000 hsc.googlegroups.com...
On May 18, 7:36 pm, "TC" <getmyemai...@yahoo.comwrote:


Hey All,
I posted this to the Crypto users group and forgot to add the VB.Net
users
group. I apologize for any confusion.
I have been testing a try / catch / finally block and purposely raising
exceptions and I've noticed that if an exception of "Length of the data
to
decrypt is invalid." is raised with the CryptoStream object, later this
exception will get raised a second time and thrown to the caller when
trying
to close the stream in a Finally block.
For example:
Try
' Do tasks that cause CryptoStream to throw invalid length while
decrypting
Catch ex as CryptographicException
' Handle exception here
Finally
If Not MemStream is Nothing then
' No 2nd exception thrown here
MemStream.Close()
End If
If Not CrypStream is Nothing then
' Exception thrown a 2nd time
CrypStream.Close()
End If
Has anyone else experienced the above?
If so, how to address the problem or is this a bug?

TC,
Do you experience the same problem when you use "Using-End Using"
statement instead of Try-Catch for CryptoStream object?

Thanks,

Onur Güzel- Hide quoted text -

- Show quoted text -
Hi,
If it solves your problem, it's OK, however you can also try to put
try-catch inside Using-End Using without "Finally" because "Using-End
Using" does all the disposal operation:
MyFunction(ByVal encryptString as String) as String

Using(MyCryptoStream)
Try
' Do Crypto tasks
return MyEncryptedString

Catch ex as CryptographicException
HandleCryptoException ex
' The 'Using' block will dispose of any CryptoStream
resources
End Using
End Function
Thanks,

Onur Güzel
Jun 27 '08 #7
On May 20, 4:35 pm, "TC" <getmyemai...@yahoo.comwrote:
Hey Onur,

Perhaps better said, in C#, one can do something like the following:

Using (object1, object2, object 3)
// Perform tasks
End Using

Is there a syntax for something similar in VB.Net or does one have to nest
the 'Using' statements like this:

Using (object1)
Using(object2)
// Perform tasks
End Using
End Using

Thanks,

TC

"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message

news:72**********************************@r66g2000 hsg.googlegroups.com...
On May 19, 1:10 pm, "TC" <getmyemai...@yahoo.comwrote:
Hey Onur,
So you would recommend something like the following:
MyFunction(ByVal encryptString as String) as String
Try
Using(MyCryptoStream)
' Do Crypto tasks
return MyEncryptedString
End Using
Catch ex as CryptographicException
HandleCryptoException ex
Catch ex as Exception
HandleException(ex)
return Nothing
Finally
If Not MyMemoryStream Is Nothing Then
MyMemoryStream.Close
End If
' Do not close CryptoStream here as it causes duplicitous
exception
' The 'Using' block will dispose of any CryptoStream resources
End Function
The above does not cause the duplicitous exception to be thrown.
Thanks,
Todd
"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message
news:e7**********************************@a23g2000 hsc.googlegroups.com...
On May 18, 7:36 pm, "TC" <getmyemai...@yahoo.comwrote:
Hey All,
I posted this to the Crypto users group and forgot to add the VB.Net
users
group. I apologize for any confusion.
I have been testing a try / catch / finally block and purposely raising
exceptions and I've noticed that if an exception of "Length of the data
to
decrypt is invalid." is raised with the CryptoStream object, later this
exception will get raised a second time and thrown to the caller when
trying
to close the stream in a Finally block.
For example:
Try
' Do tasks that cause CryptoStream to throw invalid length while
decrypting
Catch ex as CryptographicException
' Handle exception here
Finally
If Not MemStream is Nothing then
' No 2nd exception thrown here
MemStream.Close()
End If
If Not CrypStream is Nothing then
' Exception thrown a 2nd time
CrypStream.Close()
End If
Has anyone else experienced the above?
If so, how to address the problem or is this a bug?
TC,
Do you experience the same problem when you use "Using-End Using"
statement instead of Try-Catch for CryptoStream object?
Thanks,
Onur Güzel- Hide quoted text -
- Show quoted text -

Hi,
If it solves your problem, it's OK, however you can also try to put
try-catch inside Using-End Using without "Finally" because "Using-End
Using" does all the disposal operation:

MyFunction(ByVal encryptString as String) as String

Using(MyCryptoStream)
Try
' Do Crypto tasks
return MyEncryptedString

Catch ex as CryptographicException
HandleCryptoException ex
' The 'Using' block will dispose of any CryptoStream
resources
End Using
End Function

Thanks,

Onur Güzel
TC,
To make sure that all of your disposable resources are disposed
clearly by Using statement, you can also use seperate "Using"s for
each disposable object like:

Using block1 As New DisposableObject1
'Statements here
End Using

Using block2 As New DisposableObject2
'Statements here
End Using

and so on...

Better ideas may exist of course.

Thanks,

Onur Güzel
Jun 27 '08 #8
On May 20, 7:36 pm, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On May 20, 4:35 pm, "TC" <getmyemai...@yahoo.comwrote:
Hey Onur,
Perhaps better said, in C#, one can do something like the following:
Using (object1, object2, object 3)
// Perform tasks
End Using
Is there a syntax for something similar in VB.Net or does one have to nest
the 'Using' statements like this:
Using (object1)
Using(object2)
// Perform tasks
End Using
End Using
Thanks,
TC
"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message
news:72**********************************@r66g2000 hsg.googlegroups.com...
On May 19, 1:10 pm, "TC" <getmyemai...@yahoo.comwrote:
Hey Onur,
So you would recommend something like the following:
MyFunction(ByVal encryptString as String) as String
Try
Using(MyCryptoStream)
' Do Crypto tasks
return MyEncryptedString
End Using
Catch ex as CryptographicException
HandleCryptoException ex
Catch ex as Exception
HandleException(ex)
return Nothing
Finally
If Not MyMemoryStream Is Nothing Then
MyMemoryStream.Close
End If
' Do not close CryptoStream here as it causes duplicitous
exception
' The 'Using' block will dispose of any CryptoStream resources
End Function
The above does not cause the duplicitous exception to be thrown.
Thanks,
Todd
"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message
>news:e7**********************************@a23g200 0hsc.googlegroups.com....
On May 18, 7:36 pm, "TC" <getmyemai...@yahoo.comwrote:
Hey All,
I posted this to the Crypto users group and forgot to add the VB.Net
users
group. I apologize for any confusion.
I have been testing a try / catch / finally block and purposely raising
exceptions and I've noticed that if an exception of "Length of the data
to
decrypt is invalid." is raised with the CryptoStream object, later this
exception will get raised a second time and thrown to the caller when
trying
to close the stream in a Finally block.
For example:
Try
' Do tasks that cause CryptoStream to throw invalid length while
decrypting
Catch ex as CryptographicException
' Handle exception here
Finally
If Not MemStream is Nothing then
' No 2nd exception thrown here
MemStream.Close()
End If
If Not CrypStream is Nothing then
' Exception thrown a 2nd time
CrypStream.Close()
End If
Has anyone else experienced the above?
If so, how to address the problem or is this a bug?
TC,
Do you experience the same problem when you use "Using-End Using"
statement instead of Try-Catch for CryptoStream object?
Thanks,
Onur Güzel- Hide quoted text -
- Show quoted text -
Hi,
If it solves your problem, it's OK, however you can also try to put
try-catch inside Using-End Using without "Finally" because "Using-End
Using" does all the disposal operation:
MyFunction(ByVal encryptString as String) as String
Using(MyCryptoStream)
Try
' Do Crypto tasks
return MyEncryptedString
Catch ex as CryptographicException
HandleCryptoException ex
' The 'Using' block will dispose of any CryptoStream
resources
End Using
End Function
Thanks,
Onur Güzel

TC,
To make sure that all of your disposable resources are disposed
clearly by Using statement, you can also use seperate "Using"s for
each disposable object like:

Using block1 As New DisposableObject1
'Statements here
End Using

Using block2 As New DisposableObject2
'Statements here
End Using

and so on...

Better ideas may exist of course.

Thanks,

Onur Güzel
However, as addition:
I tried nesting "Using"s and seems to work in VB.NET also:

Like:

Using w1 As IO.StreamWriter = IO.File.CreateText("c:\foo1.txt")
' code here
w1.Write("foo1")
Using w2 As IO.StreamWriter = IO.File.CreateText("c:\foo2.txt")
w2.Write("foo2")
End Using
End Using

Thanks,

Onur Güzel
Jun 27 '08 #9
In VB you can nest the Usings, or you can:

Using obj1 As New SomeObj1, obj2 As New SomeObj2, obj3 As New SomeObj3
...
End Using

On Tue, 20 May 2008 09:35:49 -0400, "TC" <ge**********@yahoo.com>
wrote:
>Hey Onur,

Perhaps better said, in C#, one can do something like the following:

Using (object1, object2, object 3)
// Perform tasks
End Using

Is there a syntax for something similar in VB.Net or does one have to nest
the 'Using' statements like this:

Using (object1)
Using(object2)
// Perform tasks
End Using
End Using

Thanks,

TC

"kimiraikkonen" <ki*************@gmail.comwrote in message
news:72**********************************@r66g200 0hsg.googlegroups.com...
On May 19, 1:10 pm, "TC" <getmyemai...@yahoo.comwrote:
>Hey Onur,

So you would recommend something like the following:

MyFunction(ByVal encryptString as String) as String
Try
Using(MyCryptoStream)
' Do Crypto tasks
return MyEncryptedString
End Using
Catch ex as CryptographicException
HandleCryptoException ex
Catch ex as Exception
HandleException(ex)
return Nothing
Finally
If Not MyMemoryStream Is Nothing Then
MyMemoryStream.Close
End If
' Do not close CryptoStream here as it causes duplicitous
exception
' The 'Using' block will dispose of any CryptoStream resources
End Function

The above does not cause the duplicitous exception to be thrown.

Thanks,

Todd

"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message

news:e7**********************************@a23g200 0hsc.googlegroups.com...
On May 18, 7:36 pm, "TC" <getmyemai...@yahoo.comwrote:


Hey All,
I posted this to the Crypto users group and forgot to add the VB.Net
users
group. I apologize for any confusion.
I have been testing a try / catch / finally block and purposely raising
exceptions and I've noticed that if an exception of "Length of the data
to
decrypt is invalid." is raised with the CryptoStream object, later this
exception will get raised a second time and thrown to the caller when
trying
to close the stream in a Finally block.
For example:
Try
' Do tasks that cause CryptoStream to throw invalid length while
decrypting
Catch ex as CryptographicException
' Handle exception here
Finally
If Not MemStream is Nothing then
' No 2nd exception thrown here
MemStream.Close()
End If
If Not CrypStream is Nothing then
' Exception thrown a 2nd time
CrypStream.Close()
End If
Has anyone else experienced the above?
If so, how to address the problem or is this a bug?

TC,
Do you experience the same problem when you use "Using-End Using"
statement instead of Try-Catch for CryptoStream object?

Thanks,

Onur Güzel- Hide quoted text -

- Show quoted text -

Hi,
If it solves your problem, it's OK, however you can also try to put
try-catch inside Using-End Using without "Finally" because "Using-End
Using" does all the disposal operation:
MyFunction(ByVal encryptString as String) as String

Using(MyCryptoStream)
Try
' Do Crypto tasks
return MyEncryptedString

Catch ex as CryptographicException
HandleCryptoException ex
' The 'Using' block will dispose of any CryptoStream
resources
End Using
End Function
Thanks,

Onur Güzel
Jun 27 '08 #10

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

Similar topics

8
by: Z D | last post by:
Hi, I was wondering what's the point of "finally" is in a try..catch..finally block? Isn't it the same to put the code that would be in the "finally" section right after the try/catch block?...
10
by: RepStat | last post by:
If I have code such a SqConnection cndb = new SqlConnection(connstr) SqlDataReader dr = null tr cndb.Open() SqlCommand cmd = new SqlCommand("exec mysp", cndb) dr = cmd.ExecuteReader()
7
by: Alan Paulk | last post by:
It seems to me if you have a function like this public void blah() try { blah blah; } catch
2
by: Alex | last post by:
Hi. What would happen if an exception occurs inside a Finally block and at the same time inside the try another exception was thrown without been handled by any catch? Alejandro.
23
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
26
by: Grim Reaper | last post by:
Just a quick and probably daft question... Isn't the code; Try DoSomething() Catch e As Exception HandleError(e) Finally DoThisAtTheEnd()
3
by: Arnaud Diederen | last post by:
Hello, I've been looking in the archives but found no interesting answer to my problem. I was wondering why the following code does not work in IE 5; I'd expect an alert showing 'In finally!',...
13
by: Jon Davis | last post by:
I understand that the finally sub-block will execute regardless of whether try succeeded or not. But so will code that follows try...catch. So then what is the difference between ... try {...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.