|
harold aptroot wrote: Well, I thought that was Blackwurst..?
Possibly one of his mates too, by the vote count. From their combined vote weighting it may have been Rookyworst.
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.”
|
|
|
|
|
Lol Rookyworst, I actually laughed, not just "the internet lol"
Thanks for testing that for me
|
|
|
|
|
Hi Everyone, Sorry for long code below. I thought it was the best way to express my problem. I would be glad if you could forward me to an article or could just answer the below questions. (in spite of reading many articles.I'm confused about the below issues)
- On click of a button, server/client will want server/client to do something(in addition to what's below) but I couldn't implement it.Errors and Errors
- Is it good practice to use CanRead and DataAvailable properties of NetworkStream not to face with exceptions?
- When server or client want each other to do something(two way job request) Is this implementation capable of handling it?
- On each loop at client side, I open and close connection. Is it good practice?
- Can I determine the size of the byte buffer according to the incoming stream? I currently put a random size
Thanks in advance for your patience and help.
Regards
private void AnaForm_Load(object sender, EventArgs e)
{
thdListener = new Thread(new ThreadStart(listenerThread));
thdListener.Start();
}
public void listenerThread()
{
try
{
string ipAdress = GetIP();
IPAddress IPadres = IPAddress.Parse(ipAdress);
IPEndPoint ipEndPoint = new IPEndPoint(IPadres, 8000);
TcpListener tcpListener = new TcpListener(ipEndPoint);
tcpListener.Start();
while (true)
{
listenerSocket = tcpListener.AcceptSocket();
ntrStream = new NetworkStream(listenerSocket);
if (listenerSocket.Connected)
{
if (ntrStream.CanRead)
{
byte[] byt = new byte[500];
ntrStream.Read(byt, 0, byt.Length);
MemoryStream ms = new MemoryStream(byt);
BinaryFormatter bf = new BinaryFormatter();
hashTableInfo.Clear();
hashTableInfo = (Hashtable)bf.Deserialize(ms);
}
if (msc.Name.Remove(0, 4) == hashTableInfo["MasaNo"].ToString())
{
thdHandler = new Thread(new ThreadStart(handlerThread));
thdHandler.Start();
}
}
}
}
catch (Exception)
{
}
}
public void handlerThread()
{
ntrStream = new NetworkStream(listenerSocket);
try
{
if (ntrStream.CanWrite)
{
MemoryStream msTime = new MemoryStream();
msTime = new MemoryStream();
BinaryFormatter bfTime = new BinaryFormatter();
bfTime.Serialize(msTime, hashTimes);
byte[] bellekSure = new byte[msTime.Length];
bellekSure = msTime.ToArray();
ntrStream.Write(bellekSure, 0, bellekSure.Length);
}
if (ntrStream.CanWrite)
{
MemoryStream msDrinks = new MemoryStream();
BinaryFormatter bfDrinks = new BinaryFormatter();
bfDrinks.Serialize(msDrinks, hashDrinks);
byte[] bellekKafe = new byte[msDrinks.Length];
bellekKafe = msDrinks.ToArray();
ntrStream.Write(bellekKafe, 0, bellekKafe.Length);
urunlerGuncellendi = false;
}
}
catch (Exception)
{
}
}
//Client
private void Client_Load(object sender, EventArgs e)
{
backgroundWorker1.RunWorkerAsync();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
while(true)
{
try
{
tcpClient = new TcpClient("serverName", 8000);
if (tcpClient.Connected)
{
ntrStream = tcpClient.GetStream();
MemoryStream msSip = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(msSip, htTableInfo);
byte[] byt = new byte[msSip.Length];
byt = msSip.ToArray();
if (ntrStream.CanWrite) ntrStream.Write(byt, 0, byt.Length);
if (ntrStream.CanRead)
{
byte[] bytTimes = new byte[500]; ntrStream.Read(bytTimes, 0, bytTimes.Length);
MemoryStream msTimes = new MemoryStream(bytTimes);
BinaryFormatter bfSure = new BinaryFormatter();
hashTimes.Clear();
hashTimes = (Hashtable)bfSure.Deserialize(msTimes);
if (InvokeRequired) this.Invoke(new dlgApplyTimes(applyTimes));
else applyTimes();
}
if (ntrStream.DataAvailable)
{
byte[] bellekKafe = new byte[500];
ntrStream.Read(bellekKafe, 0, bellekKafe.Length);
MemoryStream msKafe = new MemoryStream(bellekKafe);
BinaryFormatter bfKafe = new BinaryFormatter();
hashDrinks.Clear();
hashDrinks = (Hashtable)bfKafe.Deserialize(msKafe);
if (InvokeRequired) this.Invoke(new dlgApplyDrinks(applyDrinks));
else appyDrinks();
}
ntrStream.Close();
tcpClient.Close();
tcpClient = null;
}
}
catch (Exception)
{
}
Thread.Sleep(3000);
}
}
modified on Tuesday, October 5, 2010 8:42 AM
|
|
|
|
|
Message Closed
modified 23-Nov-14 5:54am.
|
|
|
|
|
So can I find the answers to all of my questions with WCF?
|
|
|
|
|
Yeah, WCF.
And, no, the server shouldn't tell the client to do anything; it merely serves.
|
|
|
|
|
Let's say the server asked client to do something. is it not possible? Then what is the way of telling client to do something and report back? and Is it also not possible in WCF?
|
|
|
|
|
It may be possible, but that is not what servers do; it's poor design.
|
|
|
|
|
Hi,
Please help me regarding a doubt. i have a .xml file which is having around 3000 nodes, now I want to retrieve the name attribute of those nodes for which store attribute>30. Please suggest the esaiest way to do it.
Thanks,
Inder....
|
|
|
|
|
Hi All,
How can we determine if a user-certificate is contained in a smartcard or if it is installed in the system itself?
I wasn't able to find a .NET class that does this?
Thanks in advance...
Sunil
|
|
|
|
|
There is no inbuilt class for smart card in .net ,
you have to use winscard.dll wrapper .
go through the below link in CP
A Smart Card Framework for .NET[^]
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
As much as i know even if a certificate comes in a card then also it has to be installed in your personal store.
While reading the cetificate you need to insert the smart token in order to execute ComputeSignature . And if you set the silent parameter to false while using ComputeSignature it will automatically reads the card and asks for password for the certificate (if any).
|
|
|
|
|
Hi all
Your help\opinion is required on a bothering subject I am debating with for a long time...
Tools: .NET 2.0, VS2005. C#
The story:
I am designing a platform that uses plugins (written by her users) and does something with them.
The plugins are mainly dll file(s) that implement some declared interface.
My platform architecture is as such:
The platform sits at certain directory (say c:\PlatformBin).
The plugins sits in user defined location (say c:\UserPlugins)
Upon starting the platform, it accepts at run time (registry key) the plugins directory, traverse and instantiate all plugins resides there.
The problem:
User plugin is eventually a dll, that implements given interface (say UserPluginDll.dll). This dll can use, if\as needed, other external dll's that needs to be in the same directory. (say User3rdPartyDll.dll)
When the platform loads the plugins, it explicitly loads the UserPluginDll.dll file (through Assembly.LoadFile(UserPluginDll.dll);). This works fine.
The problem happens when the platform actually access at runtime to the user code in the plugin, that uses the user 3rd party dll (User3rdPartyDll.dll)
The CLR can't find the relevant User3rdPartyDll.dll file and raises up an exception "file not found...").
The suggested solutions:
Here are some tricks and solutions that I have tried\disqualified:
1. Use GAC (not an option)
2. Add to the appDomain private bin path for the c:\UserPlugins directory (and its subdirectories) - not working since private bin path (and other similar tricks) is always relatively to the app bin path (c:\PlatformBin), and I don't want to create this unnecessary coupling between the users plugins directory and the platform bin directory
3. Use <Probing> element in application config file - not good (and not working as well from some reason), since the plugins directory is learnt at runtime and I don't want the user to go and edit the app config file and change the plugins directory there.
4. Use AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve method, that is raised exactly when the CLR fails to locate the necessary dll.
Summary and question:
I think I will use this forth option eventually, but it also demonstrates a compromise from my side, as it means that the CLR first have to fail and then request my help (at runtime), instead of automatically allows me to tell him at the very first beginning were else he needs to search for its missing dlls at runtime.
I would have expect that CLR will allow me to add additional search paths for searching dll's at runtime, and it drives me crazy that I can't do so !!!
Any one can help ? have other suggestions ?
-- Modified Tuesday, October 5, 2010 3:32 AM
|
|
|
|
|
Member 3941620 wrote: CLR first have to fail and then request my help
Programming by error - I love it.
Isn't there a reference path in there somewhere, maybe that can be set in the userdll.dll at runtime.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi
The solution can't come from the user code side, since the problems occures before actually access him.
In addition, I don't want to force\expect the user to be aware of my (CLR) limitations and have hime handle some technical issues, not directly relating to its domain\knowladge
If, from the other hand, you are aware of an option that allows to define the assembly, upon loading, other assemblies to load when needed - that can certainly be done from my side (the platform) and I will be happy to be notified about such an option...
Thanks
Shultz
|
|
|
|
|
An assembly has a GetReferencedAssemblies() method. Have you tried that? E.g.
string assemblyName = "c:\\UserPlugins\\UserPluginDll.dll";
string assemblyPath = System.IO.Path.GetDirectoryName(assemblyName);
Assembly assembly = Assembly.LoadFrom(assemblyName);
AssemblyName[] referenced = assembly.GetReferencedAssemblies();
List<Assembly> assemblies = new List<Assembly>();
foreach (AssemblyName an in referenced)
{
string extra = System.IO.Path.Combine(assemblyPath, an.Name + ".dll");
if (System.IO.File.Exists(extra))
{
Assembly tmpAssembly = Assembly.LoadFrom(System.IO.Path.Combine(assemblyPath, an.Name + ".dll"));
assemblies.Add(tmpAssembly);
}
}
|
|
|
|
|
Hi
I wasn't aware of that option and I will certainly test it today (when I will get back home),
I believe though, that it won't work, as the CLR can't realize that the missing assembly at runtime that he searches, has actually been loaded before, and lies at my private 'assemblies' list declared somewhere... ,Unless you can tell of a way that connects my local 'assemblies' list to the ones that CLR is aware of ?
(that is my assumption according to other threads that I have read in the subject and implied that issue..).
I will report once I will try it.
Thanks
Shultz
|
|
|
|
|
I haven't run into that problem, so I'm not sure it exists.
|
|
|
|
|
Be sure. It exists.
CLR doesn't know to search for your dynamically referenced dlls at runtime, unless they appear in its default search paths and probing dirs.
The main question in this thread is how to add him some more search directories to look at...
|
|
|
|
|
Write a little app that demonstrates what you think is a problem.
|
|
|
|
|
Any one have simple code that will determine whether the web page has fully loaded?
Can be any browser.
|
|
|
|
|
There is java script window.onload.
rahul
|
|
|
|
|
|
I need a program that run in the back end console then when the webpage is done loading then it will call another method.
|
|
|
|
|
Without hooking into the browser, you can't determine what's going on there directly from an external application. You were told this yesterday.
|
|
|
|