[lnkForumImage]
TotalShareware - Download Free Software

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


 

Lin JinCong

7/7/2004 10:16:00 AM

A serialize remoting object, when I try to upload a file to server by it,
occur error:cause security limit, cannot access type
System.Runtime.Remoting.ObjRef¡£

thanks.



attachment£ºsource code & a part of error exception info.¡£


Source Code:

[Serializable]
public class CFile: MarshalByRefObject
{
/// <summary>
/// <p>upload a file to server</p>
/// </summary>

public bool SaveFile(string RemoteFileName,FileStream stream, Encoding
encoding)
{
try
{
string strPath = Path.GetDirectoryName(RemoteFileName);
if ((strPath != "") && (!Directory.Exists(strPath)))
{
Directory.CreateDirectory(strPath);
}

int BLOCK_SIZE = 4096;
BinaryReader sr = new BinaryReader(stream, encoding);

FileStream fs = new FileStream(RemoteFileName, FileMode.Create,
FileAccess.Write);
BinaryWriter sw = new BinaryWriter(fs, encoding);

Byte[] buffer = new Byte[BLOCK_SIZE];
int bytes = 0;
int totalBytes = 0;

while(totalBytes < stream.Length)
{
bytes = (int)sr.Read(buffer, 0, BLOCK_SIZE);
totalBytes = totalBytes + bytes;
sw.Write(buffer, 0, bytes);
}

sw.Close();
sr.Close();
fs.Close();

return true;
}
catch(Exception e)
{
throw e;
}
}
}



a part of error exception info£º

{System.Runtime.Serialization.SerializationException}
[System.Runtime.Serialization.SerializationException]:
{System.Runtime.Serialization.SerializationException}
HelpLink: Nothing
InnerException: {System.Security.SecurityException}
Message: "ÓÉÓÚ°²È«ÏÞÖÆ£¬ÎÞ·¨·ÃÎÊÀàÐÍ System.Runtime.Remoting.ObjRef¡£"
Source: "mscorlib"
StackTrace: "


2 Answers

Sunny

7/7/2004 5:50:00 PM

0

Hi,
set up typeFilterLevel = "Full" both at client and server.

Sunny


In article <ehOsRqAZEHA.3228@TK2MSFTNGP12.phx.gbl>, kintsoon@hotmail.com
says...
> A serialize remoting object, when I try to upload a file to server by it,
> occur error:cause security limit, cannot access type
> System.Runtime.Remoting.ObjRef??
>
> thanks.
>
>
>
> attachment??source code & a part of error exception info.??
>
>
> Source Code:
>
> [Serializable]
> public class CFile: MarshalByRefObject
> {
> /// <summary>
> /// <p>upload a file to server</p>
> /// </summary>
>
> public bool SaveFile(string RemoteFileName,FileStream stream, Encoding
> encoding)
> {
> try
> {
> string strPath = Path.GetDirectoryName(RemoteFileName);
> if ((strPath != "") && (!Directory.Exists(strPath)))
> {
> Directory.CreateDirectory(strPath);
> }
>
> int BLOCK_SIZE = 4096;
> BinaryReader sr = new BinaryReader(stream, encoding);
>
> FileStream fs = new FileStream(RemoteFileName, FileMode.Create,
> FileAccess.Write);
> BinaryWriter sw = new BinaryWriter(fs, encoding);
>
> Byte[] buffer = new Byte[BLOCK_SIZE];
> int bytes = 0;
> int totalBytes = 0;
>
> while(totalBytes < stream.Length)
> {
> bytes = (int)sr.Read(buffer, 0, BLOCK_SIZE);
> totalBytes = totalBytes + bytes;
> sw.Write(buffer, 0, bytes);
> }
>
> sw.Close();
> sr.Close();
> fs.Close();
>
> return true;
> }
> catch(Exception e)
> {
> throw e;
> }
> }
> }
>
>
>
> a part of error exception info??
>
> {System.Runtime.Serialization.SerializationException}
> [System.Runtime.Serialization.SerializationException]:
> {System.Runtime.Serialization.SerializationException}
> HelpLink: Nothing
> InnerException: {System.Security.SecurityException}
> Message: "????&#176;??&#171;?????&#172;??&#183;?&#183;??????? System.Runtime.Remoting.ObjRef??"
> Source: "mscorlib"
> StackTrace: "
>
>
>

Lin JinCong

7/8/2004 12:57:00 AM

0

thanks for you all.


"Sunny" <sunny@newsgroups.nospam> ????
news:%23TKcQrEZEHA.556@tk2msftngp13.phx.gbl...
Hi,
set up typeFilterLevel = "Full" both at client and server.

Sunny


In article <ehOsRqAZEHA.3228@TK2MSFTNGP12.phx.gbl>, kintsoon@hotmail.com
says...
> A serialize remoting object, when I try to upload a file to server by it,
> occur error:cause security limit, cannot access type
> System.Runtime.Remoting.ObjRef??
>
> thanks.
>
>
>
> attachment??source code & a part of error exception info.??
>
>
> Source Code:
>
> [Serializable]
> public class CFile: MarshalByRefObject
> {
> /// <summary>
> /// <p>upload a file to server</p>
> /// </summary>
>
> public bool SaveFile(string RemoteFileName,FileStream stream, Encoding
> encoding)
> {
> try
> {
> string strPath = Path.GetDirectoryName(RemoteFileName);
> if ((strPath != "") && (!Directory.Exists(strPath)))
> {
> Directory.CreateDirectory(strPath);
> }
>
> int BLOCK_SIZE = 4096;
> BinaryReader sr = new BinaryReader(stream, encoding);
>
> FileStream fs = new FileStream(RemoteFileName, FileMode.Create,
> FileAccess.Write);
> BinaryWriter sw = new BinaryWriter(fs, encoding);
>
> Byte[] buffer = new Byte[BLOCK_SIZE];
> int bytes = 0;
> int totalBytes = 0;
>
> while(totalBytes < stream.Length)
> {
> bytes = (int)sr.Read(buffer, 0, BLOCK_SIZE);
> totalBytes = totalBytes + bytes;
> sw.Write(buffer, 0, bytes);
> }
>
> sw.Close();
> sr.Close();
> fs.Close();
>
> return true;
> }
> catch(Exception e)
> {
> throw e;
> }
> }
> }
>
>
>
> a part of error exception info??
>
> {System.Runtime.Serialization.SerializationException}
> [System.Runtime.Serialization.SerializationException]:
> {System.Runtime.Serialization.SerializationException}
> HelpLink: Nothing
> InnerException: {System.Security.SecurityException}
> Message: "????&#176;??&#171;?????&#172;??&#183;?&#183;??????? System.Runtime.Remoting.ObjRef??"
> Source: "mscorlib"
> StackTrace: "
>
>
>