views:

55

answers:

1

Example:

Dim Sh32 As Object = CreateObject("Shell.Application")
Dim path As String = "C:\temp\catalog.zip"
Dim sf As Object = Sh32.NameSpace(path)

-> does not work, sf = Nothing

Dim Sh32 As Object = CreateObject("Shell.Application")
Dim path As String = "C:\temp\catalog.zip"
Dim sf As Object = Sh32.NameSpace(path.ToString)

-> works

Any idea?

Clearly path = path.ToString, but they behave differently when used as COM parameters.

A: 

Hmm, I don't know the details of VB and/or COM well enough, but maybe there is a difference between a string object and a string representation?

Should be interesting to see someone "in the know" resolving the puzzle ;)

MBaas
The string type's implementation of ToString() is "return this" so that shouldn't have any effect at all. (And no, there's no difference between a string object and its representation - they're both strings.)
Eilon
I performed a series of additional tests and found out that it even suffices to double the round brackets in the statement to make it work: Dim sf As Object = Sh32.NameSpace((path)). My conclusion so far is that it is an issue of the VB.NET IL compiler
GerdR