Click here to Skip to main content
15,917,328 members
Home / Discussions / C#
   

C#

 
QuestionRe: How to cast multiple form in class Pin
RoalearK16-Apr-09 15:59
RoalearK16-Apr-09 15:59 
QuestionHow to print DataGridView using C#.Net in windows application Pin
pradeepc_mca16-Apr-09 0:01
pradeepc_mca16-Apr-09 0:01 
AnswerRe: How to print DataGridView using C#.Net in windows application Pin
Abhijit Jana16-Apr-09 0:21
professionalAbhijit Jana16-Apr-09 0:21 
QuestionHow to make a complex type visible to the client in .NET remoting and WCF? Pin
Farawin15-Apr-09 23:11
Farawin15-Apr-09 23:11 
AnswerRe: How to make a complex type visible to the client in .NET remoting and WCF? Pin
dojohansen16-Apr-09 0:54
dojohansen16-Apr-09 0:54 
GeneralRe: How to make a complex type visible to the client in .NET remoting and WCF? Pin
Farawin16-Apr-09 1:22
Farawin16-Apr-09 1:22 
GeneralRe: How to make a complex type visible to the client in .NET remoting and WCF? Pin
dojohansen16-Apr-09 3:42
dojohansen16-Apr-09 3:42 
GeneralRe: How to make a complex type visible to the client in .NET remoting and WCF? Pin
Farawin16-Apr-09 21:45
Farawin16-Apr-09 21:45 
I switched to WCF but still can't get it to work. Here is what my code looks like now:

The interface looks like this:

[ServiceContract]
public interface IBase {
int IntTest {
[OperationContract]
get;
}
String StringTest {
[OperationContract]
get;
}
IOther OtherTest {
[OperationContract]
get;
}
}

[ServiceContract]
public interface IOther {
String StringTest {
[OperationContract]
get;
}
}


It is implemented in both projects. I tried using a shared assembly but get the same result. My server now looks like this:

public partial class MainWindow : Window {
private Base fb;
private ServiceHost host;

public MainWindow() {
InitializeComponent();
fb = new Base();
host = new ServiceHost(fb, new Uri[] { new Uri("net.pipe://localhost") });
host.AddServiceEndpoint(typeof(IBase), new NetNamedPipeBinding(), "PipeReverse");
host.Open();
}

private void Window_Closing(object sender, CancelEventArgs e) {
host.Close();
}
}


And here is my implementation of the interface:

[Serializable]
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
public class Base : MarshalByRefObject, IBase {

public int IntTest {
get { return 4; }
}

public string StringTest {
get { return "A string from Base"; }
}

public IOther OtherTest {
get { return new Other(); }
}
}

[Serializable]
[DataContract]
public class Other : MarshalByRefObject, IOther {
[DataMember]
public string StringTest {
get { return "A string from Other"; }
}

}


The client looks like this:

public partial class Form1 : Form {

IBase obj;

public Form1() {
InitializeComponent();
ChannelFactory<IBase> pipeFactory =
new ChannelFactory<IBase>(
new NetNamedPipeBinding(),
new EndpointAddress(
"net.pipe://localhost/PipeReverse"));

obj = pipeFactory.CreateChannel();
}


private void button2_Click(object sender, EventArgs e) {

Console.WriteLine("Returns: " + obj.StringTest + " " + obj.StringTest.Length);
Console.WriteLine("Returns: " + obj.IntTest);
Console.WriteLine(obj.OtherTest);

}
}


Everything works like a charm except this line:

Console.WriteLine(obj.OtherTest);

It give me a CommunicationException with the message "There was an error reading from the pipe: Unrecognized error 109". As far as I can tell that is a broken pipe due to a faulted state but I can't figure out why. Any ideas?

A thanks for helping out, I'm getting so frustrated with this...
NewsInteresting Article for C# and Navision Developers Pin
abhishek pareek200915-Apr-09 23:05
abhishek pareek200915-Apr-09 23:05 
QuestionHow do you implement the auto reload process from database data in windows form for display? Pin
calendarw15-Apr-09 22:26
calendarw15-Apr-09 22:26 
AnswerRe: How do you implement the auto reload process from database data in windows form for display? Pin
Mycroft Holmes15-Apr-09 23:20
professionalMycroft Holmes15-Apr-09 23:20 
GeneralRe: How do you implement the auto reload process from database data in windows form for display? Pin
calendarw15-Apr-09 23:41
calendarw15-Apr-09 23:41 
AnswerRe: How do you implement the auto reload process from database data in windows form for display? Pin
SeMartens15-Apr-09 23:21
SeMartens15-Apr-09 23:21 
GeneralRe: How do you implement the auto reload process from database data in windows form for display? Pin
calendarw15-Apr-09 23:47
calendarw15-Apr-09 23:47 
AnswerRe: How do you implement the auto reload process from database data in windows form for display? Pin
dojohansen16-Apr-09 1:15
dojohansen16-Apr-09 1:15 
QuestionDraw text along points Pin
baranils15-Apr-09 22:22
baranils15-Apr-09 22:22 
AnswerRe: Draw text along points Pin
Henry Minute15-Apr-09 23:26
Henry Minute15-Apr-09 23:26 
GeneralRe: Draw text along points Pin
baranils16-Apr-09 0:25
baranils16-Apr-09 0:25 
GeneralRe: Draw text along points [modified] Pin
Henry Minute16-Apr-09 0:41
Henry Minute16-Apr-09 0:41 
GeneralRe: Draw text along points Pin
baranils16-Apr-09 0:56
baranils16-Apr-09 0:56 
GeneralRe: Draw text along points Pin
Henry Minute16-Apr-09 0:57
Henry Minute16-Apr-09 0:57 
GeneralRe: Draw text along points Pin
Henry Minute16-Apr-09 3:50
Henry Minute16-Apr-09 3:50 
GeneralRe: Draw text along points Pin
baranils16-Apr-09 4:04
baranils16-Apr-09 4:04 
GeneralRe: Draw text along points Pin
Henry Minute16-Apr-09 9:22
Henry Minute16-Apr-09 9:22 
GeneralRe: Draw text along points Pin
baranils16-Apr-09 10:22
baranils16-Apr-09 10:22 

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.