*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Best regards,
quansun
VS.NET, Visual C++
Microsoft
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com
Mauricio
>-----Original Message-----
>I modified your sample as the following:
>1. Modify the file App.config in the server project to
register the class
>"RetClass"
><?xml version="1.0" encoding="utf-8" ?>
><configuration>
> <system.runtime.remoting>
> <application>
> <service>
> <wellknown
> type="ByRefClass.ServerClass,ByRefClass"
> objectUri="ServerUri"
> mode="Singleton"
> />
> <wellknown
> type="ByRefClass.RetClass,ByRefClass"
> objectUri="RetClass"
> mode="Singleton"
> />
> </service>
> <channels>
> <channel ref="tcp" port="8080">
> <serverProviders>
> <formatter
ref="binary"/>
> </serverProviders>
> </channel>
> </channels>
> </application>
> </system.runtime.remoting>
></configuration>
>
>2. Modify the implementing code of GetNewClass() of the
class ServerClass
>as the following:
>
>Public Class ServerClass : Inherits MarshalByRefObject
> Private Shared m_val As Integer
> Private Shared m_retClass As RetClass
>
> Public Function GetNewObject() As RetClass
> If Me.m_retClass Is Nothing Then
> Me.m_retClass =
>CType(Activator.GetObject(Type.GetType
("ByRefClass.RetClass,ByRefClass"),
>"tcp://localhost:8080/RetClass"), RetClass)
> End If
> Return m_retClass
> End Function
>
>End Class
>
>After rebuild the sample, now it works fine. Please refer
to the attachment.
In order to workaround the issue, you could try:
1. Disable Media Sense for TCP/IP in Windows. Please refer to the article:
http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b239924
2. Specify machineName="localhost" and useIpAddress="false" on the server
channel definition as the following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
type="ByRefClass.ServerClass,ByRefClass"
objectUri="ServerUri"
mode="Singleton"
/>
</service>
<channels>
<channel ref="tcp" port="8080" machineName="localhost"
useIpAddress="false">
<serverProviders>
<formatter ref="binary"/>
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>
Best regards,