|
hdv212 wrote: all of them create a some new classes and write more complex code.
It is a complex topic.
If you are looking for some simpler implementations, then maybe look at things like UML designers or Flow Chart designers. There are a fair few of those out there.
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.”
I wouldn't let CG touch my Abacus!
|
|
|
|
|
Hi!!
i'm getting this error when i try to share screen from my notebook connected to the router using wifi n my pc by ethernet
"System.ArgumentException: Value does not fall within the expected range.
at RDPCOMAPILib.IRDPSRAPIViewer.Connect(String bstrConnectionString, String bstrName, String bstrPassword)
at AxRDPCOMAPILib.AxRDPViewer.Connect(String bstrConnectionString, String bstrName, String bstrPassword)"
this error comes each time i try to connect it
axRDPviewer.connect(Connstring,"user1", "");
I cant get this corrected...
It works perfect when i do it on my pc
but aint working when try to share my notebook screen...
the Connstring is being sent by Tcp message(Send and receive)...
Can u tell me where is the source of the problem... How can i take care of this???
|
|
|
|
|
Can you connect to your notebook when you use Microsoft's Remote Desktop? That's a good way to find out where the problem is located: e.g. remote access not allowed on your notebook, empty passwords for remote access not accepted...
|
|
|
|
|
when im using that RDPCOMAPILib, the aero style dosen't working ! how can we solve that problem!? can somebody help me ?
|
|
|
|
|
Hello Experts,
I would like to ask if what's wrong with my program. I have created 1 client and 1 server that will accept the message
of the client but I got this error.
Cross-thread operation not valid: Control 'lbConnections' accessed from a thread other than the thread it was created on.
For more details here is my code for the Client that send message to server.
using System;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
namespace UDP_Client
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
UdpClient udpClient = new UdpClient();
udpClient.Connect(tbHost.Text, 8080);
Byte[] sendBytes = Encoding.ASCII.GetBytes("Hello World?");
udpClient.Send(sendBytes, sendBytes.Length);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
Here also is the code to my server which were I got the error thats is mention above.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Net;
using System.Net.Sockets;
namespace UDP_Server
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void serverThread()
{
UdpClient udpClient = new UdpClient(8080);
while (true)
{
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
Byte[] receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
string returnData = Encoding.ASCII.GetString(receiveBytes);
lbConnections.Items.Add(RemoteIpEndPoint.Address.ToString() + ":" +
returnData.ToString()
);
}
}
private void Form1_Load(object sender, EventArgs e)
{
Thread thdUDPServer = new Thread(new
ThreadStart(serverThread));
thdUDPServer.Start();
}
}
}
Any comments or suggestion to help is kindly appreciated.
Thanks,
DAN
|
|
|
|
|
|
I have 600 xml files and I need to search through 50000 xml files to see which of those 600 exist in the 50000.
I have tried directory.getfiles and it's taking so long I could do it faster by hand I believe.
Does anyone have any ideas on how to do this efficiently? Thanks for reading.
|
|
|
|
|
Hi, I suggest you:
1. use Directory.EnumerateFiles() to avoid the full list in memory
2. which requires .NET 4.0
3. calculate a hash value for each of those files in the small set, storing them in a Dictionary<filename,hashvalue>
4. iterate over the files in the large set, calculating their hash value, then comparing the file content with the files from the small set that have matching hash values.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi Luc,
Thanks for the reply, I can't use 4.0 yet, only 3.5 
|
|
|
|
|
Without .NET 4.0 you have two choices:
1. use Directory.GetFiles()
2. use Win32 functions (GetFirstFile, GetNextFile) through P/Invoke.
I would opt for 1 until proven too inefficient.
There is actually a third way: assuming all filenames start with a letter and all letters have comparable probability, use a loop and the filtered version of GetFiles, i.e. first get all names matching a*, then b*, etc; that way you never have all of them at once.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Good thinking!
return 5;
|
|
|
|
|
A quick test on my system showed Directory.GetFiles took only 215 milliseconds to get 50000 files and Array.Contains took 277 milliseconds to find 600 filenames. Perhaps you have something else happening.
This was assuming you were searching for matched files names not content.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark,
Thanks for testing that locally, do you mind pasting some code?
I can do this locally, but would prefer to do it over the network, are you iterating locally or remotely?
|
|
|
|
|
There's your problem. You failed to indicate in you original post that you were accessing the files over a network. Of course it may be slow depending on local conditions, network usage, latency, etc.
turbosupramk3 wrote: do you mind pasting some code?
What code you need? What part can't you figure out?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Well it can be done either way, it does not have to be over the network, it seemed terribly slow in either circumstance, of course much slower over the network than locally, but terribly slow locally as well.
|
|
|
|
|
|
Just interested in opinions and suggestions regarding how to comprehensively, safely and dynamically (to allow 3rd party plugins to be callable) expose C# code through a script editor!
I'm working on a Node based Scene Graph written in C# which is near complete. It uses Reflection Emit to support a very light weight C# "script" interface ( and indeed all .net languages). Using a custom text editor, the user enters some C#, which the system concatenates into the text body of a class definition, compiles, emits and calls all at run-time etc etc
All works great, however, an obvious side effect is that a casual script user has the same access as I have within the code! This is not ideal for many reasons, but mainly as undo cant be supported at this low level. (I cant use "internal" to overly limit access as 3rd party plug-in developers must have free access)
Undo is currently supported in GUI, but in scripts only by my providing commonly needed operations as member funcs of the class within which the script is compiled into, which work in a way which can be undone... (I cant prevent the user interacting or changing with objects members, as you could do in C++ by using const)
A solution might be to emit, at run time, wrappers for every node class to provide safe indirection to actions the user performs allowing them to be undone.
I'd love to hear from anyone who has experience of anything like this or has any suggestions or observations.
Thanks!
|
|
|
|
|
I don't really get where you are going with this. From your description, I'm assuming you have a script editor window of some sort and then a UI of some sort. Inside the script editor, you can edit scripts. Outside the script editor, you can manipulate the UI in other ways. You want undo functionality. Why wouldn't the script editor window just undo changes made to the script? It would be kind of wacky for the script editor to be able to undo stuff outside of the script editor. Outside the script editor, the undo/redo would be on a more unitized level?
Also, not sure why you are using reflection for C# scripting? There are Microsoft assemblies to compile C# code.
|
|
|
|
|
Firstly, Reflection Emit IS (one of) the MS assemblies you mention needed to compile and C# (along with CodeDom/ICodeProvidor) Lets not worry about that, it all works just fine.
A unified interface for undo is in no way wacky. The purpose of a script editor is to automate and parametrise repetitive tasks the user makes in the GUI. Allowing total, destructive access to an entire application is not good practice. It also means that whether a script is called from the editor, or a gui button, the behaviour is consistent
A node based system mirrors OO principals- all user data is stored in attributes within classified nodes, so its important that the script interface is not merely a limited set of high level functions, for one because the system makes use of plugins
|
|
|
|
|
So currently I'm working on some code to dynamically trace the execution of methods in a separate DLL, once the methods complete, the trace of calls is written to a log file using a StreamWriter.
traceString = SeparateClass.TraceString;
traceFile.Write(traceString.ToString());
traceFile.Flush();
traceFile.Close()
traceFile being declared as a static global variale within the Program class.
However, some of the methods being traced, call the System.Environment.Exit(); command, which completely kill the entire app.
So...I want to use the AppDomain.ProcessExit Event handler to write the data to the log file and flush/close the file before it the app is killed.
I have defined a delegate to be set as the AppDomain.ProcessExit Event as follows...
testDomain.ProcessExit += delegate(object sender, EventArgs e)
{
traceString = SeparateClass.TraceString;
traceFile.Write(traceString.ToString());
traceFile.Flush();
traceFile.Close();
};
But...when the event is fired, I am getting NullReferenceExceptions at the first line, saying that SeparateClass is Null.
Are the values null and void as soon as AppDomain.ProcessExit is entered? If so, any idea how to close the file another way?
Thanks.
Jenni
A girl in Engineering AND IT?!...what is this nonsense?
|
|
|
|
|
Hi Jenni,
Application.Exit() and its event handler work just fine for me. Here is an example (using a Form with a Button and a Label):
using System;
using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
namespace WindowsFormsApplication2 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
log("start");
Application.ApplicationExit+=delegate(object sender, EventArgs e) {
string s=SomeTrace.TraceLog;
label1.Text="all logs: "+s;
MessageBox.Show(s);
File.WriteAllText("log.txt", s);
};
}
private void log(string s) {
label1.Text=s;
SomeTrace.log(s);
}
private void btnQuit_Click(object sender, EventArgs e) {
log("btnQuit_Click");
Application.DoEvents();
Application.Exit();
}
}
public class SomeTrace {
public static string TraceLog=DateTime.Now.ToLongTimeString();
public static void log(string s) {
TraceLog+=Environment.NewLine+s;
}
}
}
Note the behavior depends on how the app quits: closing the main form just creates the file, there will not be a MessageBox as the main form is no longer present. Clicking the Button closes the main form (due to the exit) AND shows the MessageBox.
Remarks:
1. you don't need Flush before a Close;
2. if something is already a string (I suspect TraceString is), there is no use in calling it's ToString() method;
3. I wouldn't use a static trace object, I'd rather instantiate one and pass it along
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi Luc
Thanks for that, this appears to be more of a GC issue, as the core console process hosts a DLL dynamically (which contains the SeparateClass definition). It is the hosted DLL code, inside the SeparateClas s code that calls System.Environment.Exit() .
The AppDomain.ProcessExit definition must be called when the Console process itself is exiting, rather than the hosted DLL.
So given that, the GC must have already tidied up the SeparateClass at this point?
I'm going to have to refactor anyway, so that the SeparateClass code is executed on a new thread, as I don't like it killing off my entire process.
Thanks again.
Jenni.
A girl in Engineering AND IT?!...what is this nonsense?
|
|
|
|
|
thatdiceygirl wrote: the GC must have already tidied up the SeparateClass at this point?
I don't think so, static classes never get collected at all by the GC, once the class got referenced its statics are initialized and never disappear, until the process vanishes at the Windows level.
I'm afraid you haven't figured out yet what is really going on. And I can't tell you from what you told us. Any chance your DLL is loaded through reflection, and calling its stuff is using some more code (and data) than my example does?
thatdiceygirl wrote: have to refactor anyway,
I agree. I wouldn't want a DLL to call Application.Exit(), DLL classes should be accommodating, not lethal.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Yeah the SeparateClass definition DLL is loaded via reflection, and instantiated using an interface defined in a common assembly.
foreach (Type type in assembly.GetTypes())
{
if (type.IsClass == true)
{
SeparateClass = Activator.CreateInstance(type) as ISeparateClass;
}
}
The TraceString property is called through the interface and returns a StringBuilder object, hence the .ToString() call.
A girl in Engineering AND IT?!...what is this nonsense?
|
|
|
|
|
OK, then some part of your reflection stuff is failing while the app is winding down. AFAIK there isn't a fundamental reason why ApplicationExit would be different from anything else.
If you want to go to the bottom of this, better show all relevant code including the type definitions and their scope.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|