|
First up, your post is as clear as mud. But luckily I had one over the eight for lunch so understand you.
I'd suggest a slightly different approach. Unless you actually NEED to run your app over the network then DON'T.
Write a very simple bootstrap. All it does is start up and check the installed version against the server, if they're different then it installs the new version. This gets around your problem of needing to propagate new versions manually.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
It's possible to do, but not very nice. Managed code running from a non-local (i.e.: Network) source is not trusted by default. You'll have to go to each machine (or do through policy if your on Active Directory) and configure the .NET Framework to trust the source location of the code, or trust any code that is signed with a certain certificate that you provide. Read up on Code Access Security for all the details (and there is a lot of it!).
|
|
|
|
|
Hi,
am creating appconfig file dynamically to my application folder.
it is working fine but while am uninstalling my application, everything unstalled but that appconfig not uninstalled why this is happening?
how can i uninstall appconfig also?
Thanks InAdvance
|
|
|
|
|
The logic seems to be clear, uninstall removes all it knows about, if you create the config file manually how is the uninstaller gong to know about it? Try including an empty config file in the project and edit it, I'm betting the uninstall will find it then.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
yes, you are correct.
cant we delete that app.config file during uninstallation?
|
|
|
|
|
HOW CAN WORK WITH MULTI PROCESS?
|
|
|
|
|
what is your problem exactly?
|
|
|
|
|
By switching between the processes. Why are you shouting, and what are you trying to achieve?
I are troll
|
|
|
|
|
Hy guys ! i've been trying to write up classes for a server and a client using sockets, i'm having a bit of a problem with the server : whenever i try to read incoming messages or send messages i get "Object reference not set to an instance of an object" error, this is because my streamWriter/Reader is null. My problem is that i can't figure out why they are null!? when i instance them there are no problems, but when i invoke their mothods they're null , does anybody have any ideeas ?
some code snippets might help to clear this up :
the declarations :
class Server
{
private TcpListener listner;
private Socket socketForClients;
private System.IO.StreamReader messageReader;
private System.IO.StreamWriter messageWriter;
the instantianion :
public void startSever()
{
listner.Start();
socketForClients = listner.AcceptSocket();
if (socketPentruClienti.Connected == true)
{
try
{
NetworkStream networkStream = new NetworkStream(socketForClients);
System.IO.StreamWriter messageWriter = new System.IO.StreamWriter(networkStream);
System.IO.StreamReader messageReader = new System.IO.StreamReader(networkStream);
}
catch (Exception eNetworkStream)
{
System.Windows.Forms.MessageBox.Show("EROARE : eroare la network stream\nEXCEPTIE : "+eNetworkStream.Message);
}
}
}
the invoking :
public void write(string message)
{
try
{
messageWriter.WriteLine(message);
messageWriter.Flush();
}
catch (Exception eScriere)
{
System.Windows.Forms.MessageBox.Show("EROARE : serverul nu a putut trimite mesaj\nEXCEPTIE : " + eScriere.Message);
return;
}
}
PS : some of the text is in romanian but it's nothing important
|
|
|
|
|
rareseu wrote: try
{
NetworkStream networkStream = new NetworkStream(socketForClients);
System.IO.StreamWriter messageWriter = new System.IO.StreamWriter(networkStream);
System.IO.StreamReader messageReader = new System.IO.StreamReader(networkStream);
}
catch (Exception eNetworkStream)
{
System.Windows.Forms.MessageBox.Show("EROARE : eroare la network stream\nEXCEPTIE : "+eNetworkStream.Message);
}// try/catch
This is where your problem is likely to be.
By declaring and instantiating the objects inside a code block (the try/catch block in this case) they are not visible to code outside of the block.
You have already declared the streams outside the block, so you are declaring new ones inside the block.
Just remove the bits, from inside the try block, struck out below and all should be well:
System.IO.StreamWriter messageWriter =
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Ah can't believe i missed that , thanks Henry ! i've got new problem now but i'l start a new thread if i can't figure it out
|
|
|
|
|
I want to add some Label and Button controls on a winForm with the code(not by dragging the label and button from toolbox) in the design environment(because there are many labels and buttons need to be created ),I created a component which has a right-click menu under the design environment,when selecting one item of the menu it shows a window, and there is one button in the shown window,Now I want to add the label and button into winform that the component is located after clicling this button.
Could you give some codes to domenstrate to create one button on the form by this way?
Thanks in advance!
|
|
|
|
|
Have a look in your form's designer.cs file and see how the IDE does it and replicate that in your code.
Something like:
Button button = new Button();
button.Text = "&New Button";
button.Location = new Point(12, 12);
this.Controls.Add(button);
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Dave,thank for your help.
I know if I write the code as you suggested and euecute it under the running time, It can create one button, but in the design time, If I execute the same code by running the button in the popup winform, it can not create button in the design winform. Could you give some advice? Thanks!
|
|
|
|
|
In order to do what you want, you will have to write your own version of the Windows Forms Designer. A lot of work.
Are you aware that if you hold down the Control key whilst selecting a component from the toolbox, you can then add multiple instances to your design surface by clicking in several places? To end this behaviour press the Escape key.
So, Ctrl-Click on Button control in Toolbox, move mouse over Form/Panel/whatever and click wherever you want a button. Added all the buttons? Press Escape or click on the next component you want from the Toolbox.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thank,Thank for your assist!
It seems to refer the EnvDTE80.DTE2 of VS2005, Because if we can create the label and button on the winform using code dynamically create them, it will save more time in our design phase.
But I try to find the way how to realize it.
|
|
|
|
|
If you want to add the button and a click event handler, you can do something like this:
namespace Test
{
public partial class MosForm : Form
{
public MosForm()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Button Mybutton = new Button();
Mybutton.Text = "My Button";
Mybutton.Location = new Point(12, 12);
this.Controls.Add(Mybutton);
Mybutton.Click += new EventHandler(Mybutton_Click);
}
private void Mybutton_Click(object sender, EventArgs e)
{
textBox1.Text = "All done";
}
}
}
|
|
|
|
|
|
Yes I can. Can you?
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
No.
saoda wrote: cheeks
What's that?
जय हिंद
|
|
|
|
|
It seems like an easy problem, I think you can solve it yourself with a little bit thinking.
Hint: You can use "for" or "foreach" to check every int in the array.
|
|
|
|
|
I have a Class with a from and a basic UI (Form1), from that UI I instantiate a class (in another thread) that initializes the serial port and listens for an event that is raised when data reaches the serial port (WorkerClass). in the method launched in the class I wait 10 seconds and then the thread exits.
I launch my form and send data to my serial port, as expected nothing happens
I launch the workerthread and immediately send data to my serial port, as expected the event is raised.
After 10 seconds my worker thread exits, I send more data to the serial port, then to my surprise the event is launched ?!?
Is this normal behaviour ?
Will it last or will the garbage collector clean it from memory ?
Code the worker class:
class WorkerClass
{
public delegate void addToRTBDelegate(String text);
public event addToRTBDelegate eventRTBadd;
private SerialPort comport = new SerialPort();
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine("Data received on serial port");
}
public void openCOMPort()
{
comport.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
comport.Open();
Console.WriteLine("Comport is Open");
for (int i = 1; i < 10; i++)
{
Thread.Sleep(1000);
}
Console.WriteLine("exited loop");
}
}
Here is my Output:
Test-Form-Thread-2.vshost.exe' (Managed): Loaded 'D:\ISS\C-SHarp\Test-From-Worker-1\Test-Form-Thread-2\bin\Debug\Test-Form-Thread-2.exe', Symbols loaded.
Comport is Open
Data received on serial port
The thread 0x27cc has exited with code 0 (0x0).
exited loop
Data received on serial port
Data received on serial port
What is happening is:
1. Start the main thread
2. Start the worker and get in a loop in the worker with a sleep
in the mean time the handler for the event is active and when data reaches the serial port, the handler sends a console message. (This is expected)
3. The worker thread exits
Now the strange part, the even handler is still active and will fire when data is received on the SP after the worker thread has terminated.
Seeing the threads runnning at various points (see below) I suspect the event handler creates a new thread that is not closed when the worker exits.
Threads before I start the worker
~ 15648 [Thread Ended]
0 4736 Worker Thread <No Name> Highest 0
0 13456 Worker Thread <No Name> Normal 0
0 13632 Worker Thread <No Name> Normal 0
0 15912 Worker Thread <No Name> Normal 0
0 11144 Worker Thread vshost.RunParkingWindow Normal 0
0 14892 Worker Thread .NET SystemEvents Normal 0
0 > 10840 Main Thread Main Thread Test_Form_Thread_2.Program.Main Normal 0
While the worker is running
~ 15648 [Thread Ended]
0 4736 Worker Thread <No Name> Highest 0
0 13456 Worker Thread <No Name> Normal 0
0 13632 Worker Thread <No Name> Normal 0
0 15912 Worker Thread <No Name> Normal 0
0 11144 Worker Thread vshost.RunParkingWindow Normal 0
0 14892 Worker Thread .NET SystemEvents Normal 0
0 > 10840 Main Thread Main Thread Test_Form_Thread_2.Program.Main Normal 0
0 15240 Worker Thread ThreadClass1 Test_Form_Thread_2.WorkerClass.openCOMPort Normal 0
0 3208 Worker Thread <No Name> Normal 0
0 12668 Worker Thread <No Name> Normal 0
After the worker exited
( the event is still activated when data reaches the serial port)
~ 15648 [Thread Ended]
0 4736 Worker Thread <No Name> Highest 0
0 13456 Worker Thread <No Name> Normal 0
0 13632 Worker Thread <No Name> Normal 0
0 15912 Worker Thread <No Name> Normal 0
0 11144 Worker Thread vshost.RunParkingWindow Normal 0
0 14892 Worker Thread .NET SystemEvents Normal 0
0 > 10840 Main Thread Main Thread Test_Form_Thread_2.Program.Main Normal 0
0 3208 Worker Thread <No Name> Normal 0
0 12668 Worker Thread <No Name> Normal 0
It is interesting to see that the worker thread is gone but threads 3208 and 12668 still exist
Is this normal behaviour ?
Thanks in advance
|
|
|
|
|
You don't need to start your own thread - SerialPort manages this for you.
The SerialPort.DataReceived event is always raised on a separate ( thread pool ) thread. Check Thread.Current.ManagedThreadId in your port_DataReceived handler.
As long as comport is alive, this event will be raised when data is received.
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Thanks for the answer Nick, I am still a bit lost here.
Ok, serial port will raise an event as long as the port was open but how can port_DataReceived display in on COnsole.writeline if the thread for port_DataReceived is ended ?
|
|
|
|
|
Your thread running openCOMPort is not doing anything. It attaches the event handler and opens the port, but this can run on your UI thread as it doesn't take any time. Then your thread sleeps for 10 seconds before ending. It can't do anything useful when its sleeping, so it's totally pointless.
When data arrives at the port, the SerialPort instance gets a thread pool thread and raises the event on that, so port_DataReceived actually runs on a thread pool thread - see my previous reply.
You're not going to get this done today. I suggest you read http://www.albahari.com/threading/[^] over the weekend.
Nick
----------------------------------
Be excellent to each other
|
|
|
|