|
Hi,
in C# all callable code units are called methods, whether they return something or not (as opposed to Fortran or Basic subroutines and functions). And the behavior of parameters is independent of the return type.
So I suggest to check your facts again; if need be, show us the one that works well and the one that fails.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Since you are speaking about a Service Reference, I assume you are using WCF.
Apparently, WCF supports out parameters in operations (I didn't think it did), but can have some tricky behaviors with them (look this discussion, for instance).
I strongly suggest you to refactor it by changing the out parameter to return value, since your method don't already has one. Really, that will be effectively the same.
|
|
|
|
|
Yes, I am using WCF on a pipe between two applications, and yes I did notice the change in position of the input and output parameters but this isn't the problem.
If a have a method public bool mymethod (string abc, out string def) and call this method on in my other project, I can see output parameter and when I run the project a is returned. So, no great issues there, but if I change the method to public void (string abc, out string def) and go back to my project I only ever see the input parameter.
Any ideas?
|
|
|
|
|
AndyASPVB wrote: Any ideas?
Yes, refactor your code to not use out parameters. It is not a recommended design for WCF implementation and if you use a code analyzer it will flag this as a design issue that should be reviewed.
only two letters away from being an asset
|
|
|
|
|
Edit: It seems i have missread your post, if this doesn't help i am sorry
You didn't explain properly. There can be either solution, depends on your need
you can use ref keyword
Int32 getDouble = 6;
DoubleIt(ref getDouble);
public void DoubleIt(ref Int32 nevVal)
{
nevVal = nevVal * 2;
}
You can use Property
public class A
{
public A(){}
private Int32 _subInt;
public Int32 unit
{
get
{
return _subInt * 2;
}
set
{
subInt = value;
}
}
}
A a = new A();
a.unit = 4;
MessageBox.Show(a.unit.ToString());
|
|
|
|
|
can anybody help
i do have both window and web application that have to work on the same database file. they work fine in design time together I mean before deploying. Now i have deployed them independently and work fine except they can't share the database file.
the main problem is the windows application is installed in C:\program files...
while the web application is installed in the file path C:\inetpub\wwwroot\..
|
|
|
|
|
Djtech01 wrote: the main problem is the windows application is installed in C:\program files...
while the web application is installed in the file path C:\inetpub\wwwroot\..
of course they are. Why is that a problem ? Is it an access file ? Did you write your windows app to require the DB to be in the same folder as the exe ? If they share the same DB, that must mean that the windows app is designed to run on the server ? You need to give more details if you want help.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
First of all, thank you
secondly, sorry for the reason that I became silent, It is because I wasn't connected to the internet for the last 20 hrs.
the database file is SQL
Christian Graus wrote: Did you write your windows app to require the DB to be in the same folder as the exe ?
yes that is the problem. the windows app will search the database in the same location as the exe.
Christian Graus wrote: If they share the same DB, that must mean that the windows app is designed to run on the server ?
yea the windows app is designed to run on the server
hope to hear from you soon
thank you
|
|
|
|
|
I guess you don't want help then ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I have made server with this code and in new form. When I push button that loads this form it stops.
private void server_Load(object sender, EventArgs e)
{
Int32 port = 1111;
IPAddress localAddr = IPAddress.Parse("127.0.0.1");
TcpListener tcpListener = new TcpListener(localAddr, port);
tcpListener.Start();
Console.WriteLine("Strežnik pognan...");
try
{
Socket socketForClient = tcpListener.AcceptSocket();
while (true)
{
if (socketForClient.Connected)
{
MessageBox.Show("Odjemalec povezan " + socketForClient.RemoteEndPoint.ToString(), "Napaka", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
NetworkStream networkStream = new NetworkStream(socketForClient);
StreamWriter streamWriter = new StreamWriter(networkStream);
StreamReader streamReader = new StreamReader(networkStream);
string line = streamReader.ReadLine();
textBox1.Text = "Sprejeto: " + line;
line = line.ToUpper();
streamWriter.WriteLine(line);
Console.WriteLine("Poslano: " + line);
streamWriter.Flush();
Console.WriteLine();
}
socketForClient.Close();
}
}
catch (Exception x)
{
Console.WriteLine(x.ToString());
}
When i connect client(also new form) to it..client form opens(client connected) but server form still isn't responding. Now i would like to type something in client and this message would be also writen lets say in textbox in server. If i delete while(true) it works but only first time. What should i do that it would work multiple times.
Please help
|
|
|
|
|
Hi,
IMO there are a few problems:
1.
Socket socketForClient = tcpListener.AcceptSocket(); is a blocking call, which means it returns only when the connection is established. So the thread will have to wait; as the code seems to be inside a Form's Load handler, that Form will not show nor function as long as you don't have a connection.
2.
the whole if (socketForClient.Connected)... statement sits inside a while loop which has no way to terminate, so your code will never finish the Load handler, your Form will never become alive.
The solution to both problems is to use a separate thread; that way your Form can start, and react to your operations, while the other thread deals with the networking. Handlers running on the GUI thread (such as a Load handler) should never take more than some 30 milliseconds, which basically means all networking should always be performed by some other thread.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Ok i changed it somehow now..it works now.. now next step for me is to transfer data for drawing. Lets say i draw circle in client..how to send data(x,y,width,heigth,colour) of it to server, so circle would be also drawn there?
Thanks,
Bye
|
|
|
|
|
So you need to define a "language" that you will use to communicate between both apps; it must cover all the functionality you plan to support. First decision is text versus binary; text is the preferred way for portability and ease of debugging; binary would be somewhat more compact and faster. Go for text!
example (just one from an infinite number of possibilities; each #x is a number):
color,#r,#g,#b;
circle,#x,#y,#w,#h;
end;
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
For the first time i send string to server it works..second time it gives me this error:
<br />
A first chance exception of type 'System.InvalidOperationException' occurred in System.dll<br />
An unhandled exception of type 'System.InvalidOperationException' occurred in System.dll<br />
<br />
Additional information: The operation is not allowed on non-connected sockets.<br />
<br />
The thread 'vshost.RunParkingWindow' (0xf94) has exited with code 0 (0x0).<br />
The program '[6184] server_client.vshost.exe: Managed' has exited with code -532459699 (0xe0434f4d).<br />
I am getting something for sockets..but on server_load sockets starts and they don't stop. Do i have to make new socket for every new string i send? I am beginner here so plz don't judge me if i ask simple questions.
Thanks for any help
modified on Thursday, October 8, 2009 11:47 AM
|
|
|
|
|
why would you open and close the connection and the streams all the time? can't you just set them up once and keep them open?
That would imply you turn some of those variables into class members of course.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Here is my code for sending:
private void poslji()
{
novo = textbox();
NetworkStream networkStream = odjemalec.GetStream();
StreamReader streamReader = new StreamReader(networkStream);
StreamWriter streamWriter = new StreamWriter(networkStream);
streamWriter.WriteLine(novo);
Console.WriteLine("Pošiljam sporočilo...");
streamWriter.Flush();
string s = streamReader.ReadLine();
textBox1.Text = s;
Console.WriteLine("Prejemam sporočilo...");
Console.WriteLine(s);
streamReader.Close();
streamWriter.Close();
networkStream.Close();
}
And here is code for server in server_load form:
try
{
IPAddress ipAd = IPAddress.Parse("127.0.0.1");
TcpListener myList = new TcpListener(ipAd, int.Parse("1111"));
myList.Start();
Socket socketForClient = myList.AcceptSocket();
Console.WriteLine("Odjemalec povezan " + socketForClient.RemoteEndPoint.ToString());
NetworkStream networkStream = new NetworkStream(socketForClient);
StreamWriter streamWriter = new StreamWriter(networkStream);
StreamReader streamReader = new StreamReader(networkStream);
string line = streamReader.ReadLine();
Console.WriteLine("Sprejeto: " + line);
line = line.ToUpper();
textBox1.Text = line;
streamWriter.WriteLine(line);
Console.WriteLine("Poslano: " + line);
streamWriter.Flush();
Console.WriteLine();
it sends first time..next time error that i pasted in post before.
|
|
|
|
|
Hello everyone, It has been long time I am trying to solve or deal with two ro more version of Excel file. It works for one not for others. Really don't know how to Accommodate all the different excel version in one project.
My Application works only with 2007 version.(The application in c#)
Jashim
|
|
|
|
|
You're using the office primary interop assemblies version 12, you must also use the PIA's for version 11 which is office 2003.
|
|
|
|
|
hi,
I have a mainform(singleton)and a sub class which does a time related job and needs to show a messagebox at the end of the job. That's where the problem is. The mbox is shown but as soon as I click to OK button on mbox, program gives an exception. I changed my code in different ways but same result.
thanks in advance
|
|
|
|
|
Dunno. What Exception? Have you run it in the debugger?
|
|
|
|
|
yes I ran it in the Debugger and it says "Couldn't find the instance of the object" and goes to the line below in Program.cs file
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(MainForm.Instance); //this is the line
}
Note: when I remove the code for showing messagebox, everything is okay
modified on Wednesday, October 7, 2009 1:52 PM
|
|
|
|
|
Where is MainForm defined? Is it the encapsulating class? Is Instance a static field? Is Instance instantiated? Any of these could be a problem. If MainForm is the encapsulating class, and this is all the code, then I would say, you need to add
MainForm.Instance = new <typename>() ;
Good luck.
In Christ,
Aaron Laws
|
|
|
|
|
as a newbee,I'll try to answer.
mainform isn't defined somewhere,I made mainform a static singleton and all other classes access mainform members through its instance by saying: MainForm.Instance.xxxxx
|
|
|
|
|
Set a breakpoint where you show the MessageBox and step from there.
|
|
|
|
|
I have a form: when the user fills a form, the application takes this information and creates a data file (.csv) and put it (data file) on the server in a directory (name of this directory is [information]) where the web site is located.
using (System.IO.StreamWriter SW = new System.IO.StreamWriter(Server.MapPath("save/information/Data_" + strDate + ".csv")))
{
SW.WriteLine(s.FirstName + ";" + s.LastName + ";" + s.Address1 + ";");
SW.Close();
}
After, I changed the path for save the file, in a different server than the Web server
StreamWriter SW = new StreamWriter(@"\\111.222.1.00\c$\Inetpub\wwwroot\site_toto\ save\information\Data_" + strDate + ".csv");
It must disable the firewall on server so that it works. I can’t it.
So instead of filing the file with system Windows, I'd like to put with FTP protocole on another place, but I do not know how I can do.
I have a class! How can I integrate it?
Is that correct if I do like that ? :
using (FTP ftplib = new FTP(MapPath ("Data_" + strDate + ".csv")));
try
{
ftplib.Connect("ftp.toto.com",
"tata",
"pata");
ftplib.ChangeDir("information/");
}
catch(Exception ex)
{
Console.WriteLine(s.FirstName + ";" + s.LastName + ";" + s.Address1 + ";");
}
try
{
int perc = 0;
ftplib.OpenDownload("Data_" + strDate + ".csv", true);
while(ftplib.DoDownload() > 0)
{
perc = (int)((ftplib.BytesTotal * 100) / ftplib.FileSize);
Console.Write("\rDownloading: {0}/{1} {2}%",
ftplib.BytesTotal, ftplib.FileSize, perc);
Console.Out.Flush();
}
Console.WriteLine("");
}
catch(Exception ex)
{
Console.WriteLine("");
Console.WriteLine(ex.Message);
}
What do you think of my integration code that you see above? is that this can work or I'm completely wrong
|
|
|
|