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.FileS tream =
System.IO.File. Open(OpenFileDi alog1.FileName, IO.FileMode.Ope nOrCreate)
Dim mstream As New System.IO.Memor yStream
Dim dat(fstream.Len gth - 1) As Byte
fstream.Read(da t, 0, fstream.Length)
mstream.Write(d at, 0, fstream.Length)
fstream.Close()
dms.WriteFile(" d:\dms\webs\ima ges\" & CInt(_StockNo) & ".jpg", mstream)
mstream.Close()
-----------------------------------------------------
Server Code (called by remoting).
Public Sub WriteFile(ByVal filename As String, ByVal Dat As
System.IO.Memor yStream)
' write a file
Try
Dim file As System.IO.File
Dim stream As System.IO.FileS tream = file.Open(filen ame,
FileMode.OpenOr Create)
stream.Write(Da t.GetBuffer, 0, Dat.Length)
stream.Close()
Catch
End Try
End Sub
=============== == 5 1384
Lookup 'FileIOPermissi ons' because I think you need to set the write
permission to that file
Set the permission
Assert the permission
Do file handling here
RevertAssert
fp (file permissions) = nothing
"Simon Verona" wrote: 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.FileS tream = System.IO.File. Open(OpenFileDi alog1.FileName, IO.FileMode.Ope nOrCreate)
Dim mstream As New System.IO.Memor yStream
Dim dat(fstream.Len gth - 1) As Byte
fstream.Read(da t, 0, fstream.Length)
mstream.Write(d at, 0, fstream.Length)
fstream.Close()
dms.WriteFile(" d:\dms\webs\ima ges\" & CInt(_StockNo) & ".jpg", mstream)
mstream.Close()
-----------------------------------------------------
Server Code (called by remoting). Public Sub WriteFile(ByVal filename As String, ByVal Dat As System.IO.Memor yStream)
' write a file
Try
Dim file As System.IO.File
Dim stream As System.IO.FileS tream = file.Open(filen ame, FileMode.OpenOr Create)
stream.Write(Da t.GetBuffer, 0, Dat.Length)
stream.Close()
Catch
End Try
End Sub =============== ==
I'll check that out... the file that it is trying to write doesn't exist....
Regards
Simon
"Crouchie19 98" <Cr**********@d iscussions.micr osoft.com> wrote in message
news:B7******** *************** ***********@mic rosoft.com... Lookup 'FileIOPermissi ons' because I think you need to set the write permission to that file
Set the permission
Assert the permission
Do file handling here
RevertAssert
fp (file permissions) = nothing "Simon Verona" wrote:
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.FileS tream = System.IO.File. Open(OpenFileDi alog1.FileName, IO.FileMode.Ope nOrCreate)
Dim mstream As New System.IO.Memor yStream
Dim dat(fstream.Len gth - 1) As Byte
fstream.Read(da t, 0, fstream.Length)
mstream.Write(d at, 0, fstream.Length)
fstream.Close()
dms.WriteFile(" d:\dms\webs\ima ges\" & CInt(_StockNo) & ".jpg", mstream)
mstream.Close()
-----------------------------------------------------
Server Code (called by remoting). Public Sub WriteFile(ByVal filename As String, ByVal Dat As System.IO.Memor yStream)
' write a file
Try
Dim file As System.IO.File
Dim stream As System.IO.FileS tream = file.Open(filen ame, FileMode.OpenOr Create)
stream.Write(Da t.GetBuffer, 0, Dat.Length)
stream.Close()
Catch
End Try
End Sub =============== ==
Aha. So, you should use the permissions to create & write to the file then.
You never mentioned the file never existed, did you?
"Simon Verona" wrote: I'll check that out... the file that it is trying to write doesn't exist....
Regards Simon "Crouchie19 98" <Cr**********@d iscussions.micr osoft.com> wrote in message news:B7******** *************** ***********@mic rosoft.com... Lookup 'FileIOPermissi ons' because I think you need to set the write permission to that file
Set the permission
Assert the permission
Do file handling here
RevertAssert
fp (file permissions) = nothing "Simon Verona" wrote:
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.FileS tream = System.IO.File. Open(OpenFileDi alog1.FileName, IO.FileMode.Ope nOrCreate)
Dim mstream As New System.IO.Memor yStream
Dim dat(fstream.Len gth - 1) As Byte
fstream.Read(da t, 0, fstream.Length)
mstream.Write(d at, 0, fstream.Length)
fstream.Close()
dms.WriteFile(" d:\dms\webs\ima ges\" & CInt(_StockNo) & ".jpg", mstream)
mstream.Close()
-----------------------------------------------------
Server Code (called by remoting). Public Sub WriteFile(ByVal filename As String, ByVal Dat As System.IO.Memor yStream)
' write a file
Try
Dim file As System.IO.File
Dim stream As System.IO.FileS tream = file.Open(filen ame, FileMode.OpenOr Create)
stream.Write(Da t.GetBuffer, 0, Dat.Length)
stream.Close()
Catch
End Try
End Sub =============== ==
Ok, just in case anybody else sees this thread with the same problem.
The problem has nothing to do with file permissions, nor whether the file
actually exists at all.
It's to do with the way the .Net framework handles and serializes streams in
v1.1 of the Framework.
For further details please see http://blogs.msdn.com/sanpil/archive.../23/78754.aspx
This works for smallish files <320kb..... Apparently, above this level the
Framework serializes the files using a different methodology which is much
less efficient. For a better solution on larger files see http://www.genuinechannels.com/Conte...x?id=23&type=1.
The solution I used was to change my memorystream for a bytearray... This is
much faster in any case :)
(acknowledgemen ts to Ken Kolda in microsoft.publi c.dotnet.remoti ng
newsgroup who gave me the pointers and the answers)
Regards
Simon
"Crouchie19 98" <Cr**********@d iscussions.micr osoft.com> wrote in message
news:AD******** *************** ***********@mic rosoft.com... Aha. So, you should use the permissions to create & write to the file then.
You never mentioned the file never existed, did you?
"Simon Verona" wrote:
I'll check that out... the file that it is trying to write doesn't exist....
Regards Simon "Crouchie19 98" <Cr**********@d iscussions.micr osoft.com> wrote in message news:B7******** *************** ***********@mic rosoft.com... > Lookup 'FileIOPermissi ons' because I think you need to set the write > permission to that file > > Set the permission > > Assert the permission > > Do file handling here > > RevertAssert > > fp (file permissions) = nothing > > > > "Simon Verona" wrote: > >> 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.FileS tream = >> System.IO.File. Open(OpenFileDi alog1.FileName, >> IO.FileMode.Ope nOrCreate) >> >> Dim mstream As New System.IO.Memor yStream >> >> Dim dat(fstream.Len gth - 1) As Byte >> >> fstream.Read(da t, 0, fstream.Length) >> >> mstream.Write(d at, 0, fstream.Length) >> >> fstream.Close() >> >> dms.WriteFile(" d:\dms\webs\ima ges\" & CInt(_StockNo) & ".jpg", >> mstream) >> >> mstream.Close() >> >> ----------------------------------------------------- >> >> Server Code (called by remoting). >> >> >> >> Public Sub WriteFile(ByVal filename As String, ByVal Dat As >> System.IO.Memor yStream) >> >> ' write a file >> >> Try >> >> Dim file As System.IO.File >> >> Dim stream As System.IO.FileS tream = file.Open(filen ame, >> FileMode.OpenOr Create) >> >> stream.Write(Da t.GetBuffer, 0, Dat.Length) >> >> stream.Close() >> >> Catch >> >> End Try >> >> End Sub >> >> >> >> =============== == >> >> >>
Download the .NET Framework SDK & look it up yourself.
In your original post you said its to do with security. Therefore, if you
use code access security to read/write your file it should solve the issue.
Your second post tells me that the file doesn't exist, which is now
different from your original post.
Use a Try-Catch-End Try block around the code that is erroring & use
MessageBox.Show (ex.ToString()) to get the full error. Then post pack your
findings
All I am trying to do is help you, but if you keep changing your mind as to
what the problem is then its not that easy to solve, is it?
"Simon Verona" wrote: Ok, just in case anybody else sees this thread with the same problem.
The problem has nothing to do with file permissions, nor whether the file actually exists at all.
It's to do with the way the .Net framework handles and serializes streams in v1.1 of the Framework.
For further details please see http://blogs.msdn.com/sanpil/archive.../23/78754.aspx
This works for smallish files <320kb..... Apparently, above this level the Framework serializes the files using a different methodology which is much less efficient. For a better solution on larger files see http://www.genuinechannels.com/Conte...x?id=23&type=1.
The solution I used was to change my memorystream for a bytearray... This is much faster in any case :)
(acknowledgemen ts to Ken Kolda in microsoft.publi c.dotnet.remoti ng newsgroup who gave me the pointers and the answers)
Regards Simon "Crouchie19 98" <Cr**********@d iscussions.micr osoft.com> wrote in message news:AD******** *************** ***********@mic rosoft.com... Aha. So, you should use the permissions to create & write to the file then.
You never mentioned the file never existed, did you?
"Simon Verona" wrote:
I'll check that out... the file that it is trying to write doesn't exist....
Regards Simon "Crouchie19 98" <Cr**********@d iscussions.micr osoft.com> wrote in message news:B7******** *************** ***********@mic rosoft.com... > Lookup 'FileIOPermissi ons' because I think you need to set the write > permission to that file > > Set the permission > > Assert the permission > > Do file handling here > > RevertAssert > > fp (file permissions) = nothing > > > > "Simon Verona" wrote: > >> 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.FileS tream = >> System.IO.File. Open(OpenFileDi alog1.FileName, >> IO.FileMode.Ope nOrCreate) >> >> Dim mstream As New System.IO.Memor yStream >> >> Dim dat(fstream.Len gth - 1) As Byte >> >> fstream.Read(da t, 0, fstream.Length) >> >> mstream.Write(d at, 0, fstream.Length) >> >> fstream.Close() >> >> dms.WriteFile(" d:\dms\webs\ima ges\" & CInt(_StockNo) & ".jpg", >> mstream) >> >> mstream.Close() >> >> ----------------------------------------------------- >> >> Server Code (called by remoting). >> >> >> >> Public Sub WriteFile(ByVal filename As String, ByVal Dat As >> System.IO.Memor yStream) >> >> ' write a file >> >> Try >> >> Dim file As System.IO.File >> >> Dim stream As System.IO.FileS tream = file.Open(filen ame, >> FileMode.OpenOr Create) >> >> stream.Write(Da t.GetBuffer, 0, Dat.Length) >> >> stream.Close() >> >> Catch >> >> End Try >> >> End Sub >> >> >> >> =============== == >> >> >> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sudesh Sawant |
last post by:
Hello,
We have an application which communicates using remoting. There is a server
which is a Windows Service. The server exposes an object which is a
singleton. The client is a Web Application which makes calls to the service.
We are using tcp channel which is using binaryformatter by default. The
problem is that after a certain number of remoting calls the calls dont get
through to the server. The client application makes the call and...
|
by: Sudesh Sawant |
last post by:
Hello,
We have an application which communicates using remoting. There is a server
which is a Windows Service. The server exposes an object which is a
singleton. The client is a Web Application which makes calls to the service.
We are using tcp channel which is using binaryformatter by default. The
problem is that after a certain number of remoting calls the calls dont get
through to the server. The client application makes the call and...
|
by: Martijn Damen |
last post by:
Hi,
At the moment I am trying to develop an application that uses another app
over .net remoting and having some problems with it (ok, that is ofcourse
why I am here), hope somebody can shine a light on the following:
I have been given a sample winforms app, which works without problem, I can
connect, send queries and become response from the other application.
When I try to implement this in webforms, this unfortunately does not...
|
by: Sudesh Sawant |
last post by:
Hello,
We have an application which communicates using remoting. There is a server
which is a Windows Service. The server exposes an object which is a
singleton. The client is a Web Application which makes calls to the service.
We are using tcp channel which is using binaryformatter by default. The
problem is that after a certain number of remoting calls the calls dont get
through to the server. The client application makes the call and...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |