S
Simon Verona
I have a pair of functions that I'm calling using remoting - called readfile
and writefile.
The readfile works fine when called from the client PC.
The writefile method returns an error:
"Because of security restrictions, the type System.Runtime.Remoting.ObjRef
cannot be accessed".
I'm guessing this is some sort of security restriction preventing writes to
the filesystem by remoting???
My code is as below.... Hope somebody can help.. If I put the server code
"inline" instead of using remoting it works fine.
Regards
Simon
Client Code :
Dim fstream As System.IO.FileStream =
System.IO.File.Open(OpenFileDialog1.FileName, IO.FileMode.OpenOrCreate)
Dim mstream As New System.IO.MemoryStream
Dim dat(fstream.Length - 1) As Byte
fstream.Read(dat, 0, fstream.Length)
mstream.Write(dat, 0, fstream.Length)
fstream.Close()
dms.WriteFile("d:\dms\webs\images\" & CInt(_StockNo) & ".jpg", mstream)
mstream.Close()
-----------------------------------------------------
Server Code (called by remoting).
Public Sub WriteFile(ByVal filename As String, ByVal Dat As
System.IO.MemoryStream)
' write a file
Try
Dim file As System.IO.File
Dim stream As System.IO.FileStream = file.Open(filename,
FileMode.OpenOrCreate)
stream.Write(Dat.GetBuffer, 0, Dat.Length)
stream.Close()
Catch
End Try
End Sub
=================
and writefile.
The readfile works fine when called from the client PC.
The writefile method returns an error:
"Because of security restrictions, the type System.Runtime.Remoting.ObjRef
cannot be accessed".
I'm guessing this is some sort of security restriction preventing writes to
the filesystem by remoting???
My code is as below.... Hope somebody can help.. If I put the server code
"inline" instead of using remoting it works fine.
Regards
Simon
Client Code :
Dim fstream As System.IO.FileStream =
System.IO.File.Open(OpenFileDialog1.FileName, IO.FileMode.OpenOrCreate)
Dim mstream As New System.IO.MemoryStream
Dim dat(fstream.Length - 1) As Byte
fstream.Read(dat, 0, fstream.Length)
mstream.Write(dat, 0, fstream.Length)
fstream.Close()
dms.WriteFile("d:\dms\webs\images\" & CInt(_StockNo) & ".jpg", mstream)
mstream.Close()
-----------------------------------------------------
Server Code (called by remoting).
Public Sub WriteFile(ByVal filename As String, ByVal Dat As
System.IO.MemoryStream)
' write a file
Try
Dim file As System.IO.File
Dim stream As System.IO.FileStream = file.Open(filename,
FileMode.OpenOrCreate)
stream.Write(Dat.GetBuffer, 0, Dat.Length)
stream.Close()
Catch
End Try
End Sub
=================