Remoting的问题,在线等待

cxyPioneer 2004-10-28 10:28:20
服务器调用文件复制方法失败,复制到不同目录下,它提示我服务器内部错误,在.config文件中的customErrors,这个方法在本机没有问题,是不是远程服务器跨应用程序边界

文件复制方法的类从MarshalByRefObject继承,用的是HttpChannel这个类,没有使用代理
哪位帮帮忙,最好给一些例子
...全文
221 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxyPioneer 2004-10-29
  • 打赏
  • 举报
回复
文件夹是在server,并且存在,但在不同目录下
Brunhild 2004-10-29
  • 打赏
  • 举报
回复
你的文件夹是存在于CLIENT上还是SERVER上?
remoting的远程对象是在SERVER上运行的,文件夹必须是存在于SERVER上。
cxyPioneer 2004-10-29
  • 打赏
  • 举报
回复
我复制的时候的目标目录文件夹是存在的
wjcking 2004-10-29
  • 打赏
  • 举报
回复
件夹是在server,并且存在,但在不同目录下
cxyPioneer 2004-10-28
  • 打赏
  • 举报
回复
从客户端调用的config里的customErrors错误
Jim3 2004-10-28
  • 打赏
  • 举报
回复
报的什么错误?

从哪里调用的?
cxyPioneer 2004-10-28
  • 打赏
  • 举报
回复


文件复制是在public class common : MarshalByRefObject 这个类中
public void CopyFile()
{
String[] files = Directory.GetFiles("c:\\temp");
ArrayList al = new ArrayList();

int length = al.Count;

for( int i=0;i< files.Length ; i++ )
{
string m_strTemp1 = files[i].ToString();
string m_strFileName = GetFileName( m_strTemp1 );
string m_strTemp2 = "c:\\cxy\\"+m_strFileName;
FileInfo fileInfo = new FileInfo( files[i].ToString());
FileInfo fileInfoTarget = new FileInfo(m_strTemp2);

bool flag = fileInfoTarget.Exists;
if( flag ) //已存在
{
bool f =IsFileUse( m_strTemp2 );
if( f == true ) //已使用
{
AgainExecuteCopy( m_strTemp1, m_strTemp2 );
}
else if( f == false ) //未使用
{
try
{
fileInfo.CopyTo( m_strTemp2,true );
}
catch(IOException ex)
{
//MessageBox.Show( ex.Message );
}
fileInfo = null;
fileInfoTarget = null;
}
}
else //不存在
{
fileInfo.CopyTo( m_strTemp2,true );
fileInfo = null;
fileInfoTarget = null;
}
}
}

private void AgainExecuteCopy(string _strSourcePath, string _strTargetPath )
{
int count = 0;
string m_strSourcePath = _strSourcePath;
string m_strTargetPath = _strTargetPath;

while( true )
{
if( count == 4 )
{
return;
}
System.Threading.Thread.Sleep(3000);// MessageBox.Show("Test");
count += 1;

FileInfo fileInfo = new FileInfo( m_strSourcePath );
FileInfo fileInfoTarget = new FileInfo( m_strTargetPath );
bool flag = IsFileUse( m_strTargetPath );

if( flag == true )
{
// MessageBox.Show( "未使用");
}
else
{
// MessageBox.Show("复制");
fileInfo.CopyTo( m_strTargetPath );
}
}
}

private string GetFileName(string _strPath )
{
string m_strPath = _strPath;
string m_strFileName = Path.GetFileName( m_strPath );
return m_strFileName;
}

private bool IsFileUse( string _strPath )
{
string m_strPath = _strPath;
bool flag = false;
try
{
FileStream fs = File.Open( m_strPath,FileMode.Open,FileAccess.Read,FileShare.None);
byte[] b = new byte[1024];
fs.Read( b,0,b.Length );
fs.Close();
flag = false;
}
catch(Exception ex)
{
flag = true;
}
return flag;
}

调用
string m_strIPAddress = System.Configuration.ConfigurationSettings.AppSettings["IPAddress"].ToString();
string m_strPort = System.Configuration.ConfigurationSettings.AppSettings["CommuncationPort"].ToString();
string m_str = "Http://" + m_strIPAddress + ":" + m_strPort + "/common";
DescompressionCommon.common comm = (DescompressionCommon.common) Activator.GetObject( typeof( DescompressionCommon.common ),m_str,WellKnownObjectMode.SingleCall);
comm.CopyFile();这个方法来复制
Jim3 2004-10-28
  • 打赏
  • 举报
回复
把代码贴出来

Jim3 2004-10-28
  • 打赏
  • 举报
回复
没有代理,从Temp拷贝到cxy目录

建议仔细调试一下,同时在服务端的copyfile里加一个try catch

看看到底错误发生在哪里?

我用你的代码只有一个目录不存在时才会报你说的错误
cxyPioneer 2004-10-28
  • 打赏
  • 举报
回复
还有你操作的时候是在同一目录下,有没有到别的目录下
cxyPioneer 2004-10-28
  • 打赏
  • 举报
回复
你没有使用代理
Jim3 2004-10-28
  • 打赏
  • 举报
回复
两台
cxyPioneer 2004-10-28
  • 打赏
  • 举报
回复
你是在一台机器上,还是在两台机器上测试,我在本机测试也是好的
Jim3 2004-10-28
  • 打赏
  • 举报
回复


你的目录不存在,所以出错了

Jim3 2004-10-28
  • 打赏
  • 举报
回复
没看出有什么问题

我这边测试遇到一次你说的问题,不过以后就没有了

我也不清楚,再测试一下吧
mudboy 2004-10-28
  • 打赏
  • 举报
回复
up

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧