Click here to Skip to main content
15,918,889 members
Home / Discussions / C#
   

C#

 
GeneralRe: Trim all unreadable characters Pin
El'Cachubrey6-Dec-04 0:09
El'Cachubrey6-Dec-04 0:09 
GeneralRe: Trim all unreadable characters Pin
DavidNohejl6-Dec-04 0:29
DavidNohejl6-Dec-04 0:29 
GeneralRe: Trim all unreadable characters Pin
DavidNohejl6-Dec-04 1:01
DavidNohejl6-Dec-04 1:01 
GeneralRe: Trim all unreadable characters Pin
El'Cachubrey6-Dec-04 19:51
El'Cachubrey6-Dec-04 19:51 
QuestionHow to remove the control box (The 3 buttons of a window at the top right corner) of a MDI Form? Pin
ting6685-Dec-04 22:43
ting6685-Dec-04 22:43 
AnswerRe: How to remove the control box (The 3 buttons of a window at the top right corner) of a MDI Form? Pin
Stefan Troschuetz6-Dec-04 1:11
Stefan Troschuetz6-Dec-04 1:11 
AnswerRe: How to remove the control box (The 3 buttons of a window at the top right corner) of a MDI Form? Pin
Stanciu Vlad6-Dec-04 4:35
Stanciu Vlad6-Dec-04 4:35 
Generalhelp! Serializable Pin
chinimimita5-Dec-04 22:34
chinimimita5-Dec-04 22:34 
im doing a remoting program. I'm just wondering why i always get this error message "An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll. Additional information: Because of security restrictions, the type clsServiceApp.CallContextString cannot be accessed. " on my second test in the client side.

Here's my code in the server:
public static void Main(string[] Args)
{
HttpChannel channel = new HttpChannel(8080);

ChannelServices.RegisterChannel(channel);

WellKnownServiceTypeEntry WKSTE = new WellKnownServiceTypeEntry(typeof(clsServiceApp.ContextBoundType),"TcpCBOService", WellKnownObjectMode.SingleCall);
RemotingConfiguration.RegisterWellKnownServiceType(WKSTE);

Console.WriteLine("Press enter to stop this process.");
Console.ReadLine();
}
---------------------------------
Here's my code in my middle tier:


public interface IContextBoundType
{
void ConnectToServer();
string SendToServer(string strValue);
}

public class ContextBoundType : ContextBoundObject//, IContextBoundType
{

private DateTime starttime;
private HttpChannel channel;

public ContextBoundType()
{
Console.WriteLine("#Connecting...");
starttime = DateTime.Now;
}

public void ConnectToServer()
{
channel = new HttpChannel();
ChannelServices.RegisterChannel(channel);

WellKnownClientTypeEntry remotetype = new WellKnownClientTypeEntry(typeof(ContextBoundType),"http://localhost:8080/TcpCBOService");
RemotingConfiguration.RegisterWellKnownClientType(remotetype);

// CallContext.SetData("ServerThreadData", new CallContextString(remotetype==null ? "Could not locate server" : "#Done Connecting..."));

}

public void DisConnectFromServer()
{

ChannelServices.UnregisterChannel(channel);

// CallContext.SetData("ServerThreadData", new CallContextString(remotetype==null ? "Could not locate server" : "#Done Connecting..."));

}


~ContextBoundType()
{
Console.WriteLine("ContextBoundType being collected after " + (new TimeSpan(DateTime.Now.Ticks - starttime.Ticks)).ToString() + " seconds.");
}

public DateTime GetServerTime()
{
return DateTime.Now;
}

public string SendMessageToServer(string strValue)
{
CallContext.SetData("ServerThreadData", new CallContextString(strValue));
// Console.WriteLine(strValue);
return strValue;
}

}

[Serializable]
public class CallContextString : ILogicalThreadAffinative
{

String _str ="";

public CallContextString(String str)
{
_str = str;
Console.WriteLine(str);
}

public override String ToString()
{
return _str;
}
}
-------------------------------------
Here's my code in the client side:

private void SendMessageToServer()
{
clsServiceApp.ContextBoundType();

clsServiceApp.ContextBoundType _service1 = new clsServiceApp.ContextBoundType();

lvwStatus.Items.Add("Sending messages to server...");
string s = _service1.SendMessageToServer(txtMessage.Text);
lvwStatus.Items.Add("Server already received message (" + ") <" + s.ToString() + ">");//_service.GetServerTime().ToLongTimeString() +
txtMessage.Text="";
}

private void Form1_Load(object sender, System.EventArgs e)
{
clsServiceApp.ContextBoundType _service = new clsServiceApp.ContextBoundType();
_service.ConnectToServer();
}


-chinimimita-
GeneralSave Drawing C# Pin
mathon5-Dec-04 22:20
mathon5-Dec-04 22:20 
GeneralRe: Save Drawing C# Pin
DavidNohejl6-Dec-04 0:06
DavidNohejl6-Dec-04 0:06 
GeneralRe: Save Drawing C# Pin
mathon6-Dec-04 3:01
mathon6-Dec-04 3:01 
GeneralRe: Save Drawing C# Pin
DavidNohejl6-Dec-04 10:44
DavidNohejl6-Dec-04 10:44 
GeneralRe: Save Drawing C# Pin
mathon6-Dec-04 5:45
mathon6-Dec-04 5:45 
GeneralRe: Save Drawing C# Pin
DavidNohejl6-Dec-04 10:51
DavidNohejl6-Dec-04 10:51 
GeneralAccessing webform controls in class Pin
Nilesh Hapse5-Dec-04 22:09
Nilesh Hapse5-Dec-04 22:09 
Generaldisplay data in datagrid using the datareader Pin
steve_rm5-Dec-04 19:26
steve_rm5-Dec-04 19:26 
GeneralRe: display data in datagrid using the datareader Pin
Daniel Turini5-Dec-04 20:22
Daniel Turini5-Dec-04 20:22 
QuestionHow do you map a network drive? Pin
SeanV5-Dec-04 19:25
SeanV5-Dec-04 19:25 
AnswerRe: How do you map a network drive? Pin
Daniel Turini5-Dec-04 20:24
Daniel Turini5-Dec-04 20:24 
GeneralDB and Several Systems Pin
mkomasi5-Dec-04 18:49
mkomasi5-Dec-04 18:49 
GeneralRe: DB and Several Systems Pin
Daniel Turini5-Dec-04 20:20
Daniel Turini5-Dec-04 20:20 
GeneralFind file status in C# Pin
mmsspp5-Dec-04 18:48
mmsspp5-Dec-04 18:48 
GeneralRe: Find file status in C# Pin
Daniel Turini5-Dec-04 20:15
Daniel Turini5-Dec-04 20:15 
Questionhow to do: Pin
mansoorafzal5-Dec-04 18:35
mansoorafzal5-Dec-04 18:35 
AnswerRe: how to do: Pin
Jay Shankar5-Dec-04 21:32
Jay Shankar5-Dec-04 21:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.