|
Well that changes the question a bit...
No, there is no chain like that, but you can find all the ports that are being listened to and get the process ids (PIDs) of the process that is listening on that port. You then need to enumerate the entire Windows handle table, filter out just the files that are open, get the PIDs of the owners of those handles, then match them up with the PIDs you got from the listeners pass.
This is a rather time consuming process and if you wanted to get a constant "real-time" update, you'd be using a ton of processing power because of the constant polling you'd have to do.
Oh, and all this requires admin priv's.
|
|
|
|
|
brilliant, thank you
... looks like i'll be busy for a while then!
|
|
|
|
|
I'm working on the 3 motor drivers that has their own ComPort on the computer. (yes 3 Serial Ports on the back of computer).
In the past, I've been using the do-while loops to do the Serial.Readline() to monitor the driver's response to the command. That really slows the processing and usually hangs the application very often.
I've modified the code to add the DataReceived event for each port. I've been sending lots of drivers' configuration (and gets the response back from the driver as echo as well.)
After sending all of the configuration, the other process begins.
The problem is that the drivers didn't finish sending back all of the responses before the new process begin. This caused the new process commands to be messup with communication.
Question is... how do I check if the configuration responses are completed before running the next process?
Your help would be greatly appreciated. Thanks!
|
|
|
|
|
There are a couple of ways to handle this, but it depends on how you want to work it.
The simplest solution is to set up a thread to handle each com port - that way they can use ReadLine all they want, and you don't have to worry about them hanging the UI thread or about data synchronisation. You then have to communicate between the UI and the threads - and I have no idea how complex that is for you because I don't know what you app is actually doing.
The other is to use the DataRecieved Event in the UI thread as you seem to be doing - but that has to be handled differently, because the data is not received in the form of lines - it arrives character by character (or a couple of characters at a time if the processor is busy) so you have to buffer and examine the data a bit more carefully.
Exactly which way you should go, I don't know - but without seeing any relevant code fragments, I can't tell what your code is doing at the moment, so I can't make any concrete suggestions.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
please i need to develop a video conferencing software, can anyone put me through?
|
|
|
|
|
|
Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...
A very quick search gave 157 million hits: Google: develop a video conferencing software[^]
In future, please try to do at least basic research yourself, and not waste your time or ours.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
I have created a project that works well in both Expression Web 3 and EW 4 using the preview feature.
However, when I published them to web sites. The versions published with EW3 works well Working site
However, the version published using EW4 has Internal Servet 500 error
Not Working site
The web.config files and the C# codes are provided below. I have spent days on the problem, and I am still unsure what is happening.
The following script was included in the <head> tag of my dynamic.dwt page
<script>
using System;
using System.Data.OleDb;
using System.Configuration;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string strcon = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(strcon);
con.Open();
}
}
</script>
I used the following lines in the web.config file:
<configuration>
<connectionStrings>
<add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|RegistrationDB1.mdb" providerName="System.Data.OleDb" />
<add name="Doughnut2002DBConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|Doughnut2002DB.mdb" providerName="System.Data.OleDb" />
<add name="DetailsDoughnut2002DBConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|Doughnut2002DB.mdb" providerName="System.Data.OleDb" />
</connectionStrings>
<system.web>
<pages validateRequest="false" enableEventValidation="false" enableViewStateMac="false" viewStateEncryptionMode="Never" />
</system.web>
</configuration>
PLEASE HELP.
|
|
|
|
|
Welcome to the C#-forum; I'm a WinForms-programmer, you'd probably have gotten a better response in the ASP-forum.
Doesn't ASP.NET give a bit more "detailed" error, than the mystical catch-all? I'd guess it's the version of JET/MDAC (the Microsoft Access drivers), or the read/write permission for the internet-user on that particular folder.
I suggest you open the database in Access, and find the "Upgrade to Sql Server" button. It'll convert all tables to Sql Server-format. Access isn't really designed to handle many requests from different users, and there's no file-level read/write permission to worry about once you're using Sql Server. There's a free version available, called Sql Express.
Further, I'd throw in some logging, wrap the con.open() in a try..except, and log any exceptions.
Good luck
|
|
|
|
|
This problem has been resolved.
It turned out that there was a slight difference between the code that worked and the one that did not. The Internal Server Error 500 was being casused by the following issue.
Problem: There are GridView features that are supported by the ASP.NET 3.5 version on my laptop, that was not supported by the version ASP.NET version 2.0 that the hosting server was using.
Remedy:
Remove the unsupported properties from the Gridview. They are the tags that have to do with <SortedAsceding..> or <SortedDescending…>. Then publish the file again.
CODE from the offending file.aspx
<asp:GridView runat="server" id="GridView1" AutoGenerateColumns="False" DataSourceID="DetailsFromDBDataSource" CellPadding="4" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:HyperLinkField DataTextField="ProductName" HeaderText="Product Name" NavigateUrl="hottea.aspx">
</asp:HyperLinkField>
<asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID">
</asp:BoundField>
<asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice">
</asp:BoundField>
<asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock">
</asp:BoundField>
<asp:ImageField DataImageUrlField="Details" HeaderText="Header Text">
</asp:ImageField>
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>
|
|
|
|
|
I am using MEF in my application. My application have 4 parts(class library) and a main module , the main modules responsibility is to interact with the above said parts and delegates job to them.
I have coded all the interface and abstract base classes in a library called 'Common' and refer it to all the other dlls which have classes inherit from those base classes. I moved all the base class and interface definition to the 'Common' library so that i can add reference of that dll in my main program and all the base classes and interfaces are readily available.
Is this the right way to do it? What is the other option in MEF using which i can refer to the base classes in my main module without referring to a dll.
eg:- abstract class baseAbc and interface IAbc is defined in common.dll, Is it possible to refer baseAbc and IAbc in my main module without adding reference to Common.dll
|
|
|
|
|
I used this to start learning about MEF it shows a good couple of exercise on how to use MEF etc.
http://channel9.msdn.com/Events/TechEd/NorthAmerica/2010/DEV304[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Is this you[^]?
I don't mean to sound paranoid, but there's a possibility that you couble be re-posting StackOverflow questions[^] here so you can copy the answer and get the points.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am the same guy, i posted it here because i didnt get an answer there.
|
|
|
|
|
I have a custom control called EditorSection which contains a Button control for the header and a RichTextBox control. I have another custom control called EditorContainer which can contain multiple EditorSection controls. In the EditorContainer I have a Button control for "Print All", which obviously should print all of the EditorSection controls' content.
I created a class called "PrintSection", which stores the title (header text) for each section as well as a string array for the "Lines" property of the RichTextBox in each EditorSection custom control. All is fine so far.
When I click "Print All" I would like to print each section's header title and then prints that section's content below it, which will sometimes span more than one page. This is where I have a problem. I'm not sure how to achieve multi-page printing with this setup.
Here is how I populate a List<printsection> object:
this._printSections = new List<PrintSection>();
foreach (Control child in sectionsPanel.Controls)
{
if (child is EditorSection)
{
PrintSection section = new PrintSection();
section.Name = ((EditorSection)child).SectionName;
section.Lines = ((EditorSection)child).GetLines();
this._printSections.Add(section);
}
}
The "GetLines()" method returns the "Lines" property for the RichTextBox in the EditorSection control, while "SectionName" is the section's header title.
Here is what I have tried so far with printing:
int sectionIndex = 0, lineIndex = 0;
void document_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics g = e.Graphics;
Font font = new Font(SystemFonts.DefaultFont.FontFamily.Name, 9.5f);
Font headerFont = new System.Drawing.Font(font.FontFamily.Name, 12.0f, FontStyle.Bold);
float yPos = 0;
PrintSection section = this._printSections.ElementAt(sectionIndex);
{
g.DrawString(section.Name, headerFont, Brushes.SteelBlue, 0, yPos);
yPos += (g.MeasureString(section.Name, headerFont).Height + 4f);
g.DrawLine(Pens.LightSlateGray, 0, yPos, g.MeasureString(section.Name, headerFont).Width * 2, yPos);
yPos += (g.MeasureString(section.Name, headerFont).Height);
for (int l = lineIndex; l < section.Lines.Count(); l++)
{
string line = section.Lines[l];
g.DrawString(line, font, Brushes.Black, 0, yPos);
yPos += (g.MeasureString(line, font).Height);
lineIndex++;
}
yPos += 32f;
if (sectionIndex < (this._printSections.Count - 1))
{
sectionIndex++;
e.HasMorePages = true;
}
}
}
The "sectionIndex" variable holds the zero-based index of the section currently being printed. I am able to print each section on its own page, which is desirable. However, I would eventually like to allow for printing continuously without making a new page for each section, as an option to the user.
The problem I am facing is this. How do I print the section's lines on more than one page if it doesn't fit on one page? I have the "yPos" variable which is the current position on the y-axis for printing. I have tried "if (yPos > pageHeight) { e.HasMorePages = true; }" but it doesn't print the remaining lines on a new page.
What am I doing wrong?
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
One call to the PrintPage handler is responsible for printing a single page. So if you want to be able to split sections between pages, you need to save some state information which allows the second call to the method to pick up a section part way through (just as you're currently storing sectionIndex so the next run of the method knows where to start).
|
|
|
|
|
Right. I just didn't know what I was doing wrong because I tried something like that. However, I *did* figure it out. I had to add a "break;" statement:
for (int l = lineIndex; l < section.Lines.Count(); l++)
{
string line = section.Lines[l];
g.DrawString(line, font, Brushes.Black, 0, yPos);
yPos += (g.MeasureString(line, font).Height);
lineIndex++;
if (yPos > e.PageBounds.Height)
{
e.HasMorePages = true;
break;
}
}
Because without the "break;" it was continuing the "for" loop until all lines had been processed. The "break;" causes it to go to the end of the PrintPage handler with "HasMorePages" set to true, which would pick up where it left off. I'm not sure how I skipped over that to begin with but your response seemed to set off a light bulb in my head. Thanks!
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
Hi I'm writing a client/server remote viewer (desktop sharing) application where screenshots of the desktop are sent across the network over a socket. I'd like to reduce the size of the transfer by getting the difference between the two images and then sending the difference. on the other hand difference will be merge with previous image at other end.
so anyone please guide me how could i accomplish this job. still now i send every time a complete image of the screen over the network programatically and program at other end just show that image. i feel huge data is getting pass over the network and screen update rate at the other end is slow. so please show me good way how to compare between two images and send only difference to other end. also tell me how to merge the difference with actual image at other end.
1) lots of free code and library is available for image comparison but i just do not understand which one i should use and which one would very faster for comparison. so just guide me regarding this.
2) and the most important part is how to send difference only over the network and merge the difference with actual image at other end
i tried lot to get some info regarding my point 2 but got nothing similar. no article i found who can guide me that how to send difference only over the network and merge the difference with actual image at other end
so i am looking for in-depth discussion for my point 2 specially. thanks
tbhattacharjee
|
|
|
|
|
Why re-invent the wheel what you can use a library that does all this for you, such as VNCSharp[^]
|
|
|
|
|
This is one of those questions where you're asking us to do everything for you – and a copy and paste job from another forum judging by the formatting.
You need to (i) make a reversible diff (i.e. something which fully encodes the differences), (ii) send it, and (iii) apply it at the other end. The libraries that you say you've found for (i) should also do (iii), and (ii) is trivial. You need to actually try and then you can come back with specific problems.
|
|
|
|
|
|
My application is C# .net Framework 3.5.
The main functionality of the application is:
let the user choose a network interface card (NIC)
assign to the user selected NIC an IP address (and subnet mask) - I use WMI - EnableStatic method of Win32_NetworkAdapterConfiguration class.
start through a Process a 3rd party C++ exe component, behaving like a server, which will be listening to the given IP address - the binding functionality is implemented by the server, so on Process start up I just give pass the proper IP address and it starts listening on that one.
Operation 2 and 3 can be repeated an unlimited number of times, thus it's possible to assign to the very same NIC several IP addresses and have multiple servers, each one listening to the its own IP address.
To assign the IP address to the given NIC I use WMI, in particular this code, where adapterGUID is the GUID of the user selected NIC and newSettings it's a class holding a list of IPs and subnet masks:
public static bool ChangeNetworkInterfaceIPs(string adapterGUID, IpSettings newSettings)
{
try
{
if (String.IsNullOrEmpty(adapterGUID))
throw new ArgumentException("adapterGUID");
ManagementBaseObject inPar = null;
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
ManagementObject moTarget = null;
foreach (ManagementObject mo in moc)
{
if ((string) mo["SettingID"] == adapterGUID)
{
moTarget = mo;
break;
}
}
if (moTarget == null)
{
mc = null;
return false;
}
object winsSecondary = moTarget.GetPropertyValue("WINSSecondaryServer");
object gateways = moTarget.GetPropertyValue("DefaultIPGateway");
object dnsDomain = moTarget.GetPropertyValue("DNSDomain");
object dnsServers = moTarget.GetPropertyValue("DNSServerSearchOrder");
object winsPrimary = moTarget.GetPropertyValue("WINSPrimaryServer");
if (newSettings.DHCP)
{
inPar = moTarget.GetMethodParameters("EnableDHCP");
moTarget.InvokeMethod("EnableDHCP", inPar, null);
}
else
{
inPar = moTarget.GetMethodParameters("EnableStatic");
inPar["IPAddress"] = newSettings.Ips;
inPar["SubnetMask"] = newSettings.Netmasks;
moTarget.InvokeMethod("EnableStatic", inPar, null);
}
if (gateways != null && !newSettings.DHCP)
{
inPar = moTarget.GetMethodParameters("SetGateways");
inPar["DefaultIPGateway"] = gateways;
outPar = moTarget.InvokeMethod("SetGateways", inPar, null);
}
if (dnsDomain != null && !newSettings.DHCP)
{
inPar = moTarget.GetMethodParameters("SetDNSDomain");
inPar["DNSDomain"] = dnsDomain;
outPar = moTarget.InvokeMethod("SetDNSDomain", inPar, null);
}
if (dnsServers != null && !newSettings.DHCP)
{
inPar = moTarget.GetMethodParameters("SetDNSServerSearchOrder");
inPar["DNSServerSearchOrder"] = dnsServers;
outPar = moTarget.InvokeMethod("SetDNSServerSearchOrder", inPar, null);
}
if (winsPrimary != null && !newSettings.DHCP)
{
inPar = moTarget.GetMethodParameters("SetWINSServer");
inPar["WINSPrimaryServer"] = winsPrimary;
if (winsSecondary != null)
{
inPar["WINSSecondaryServer"] = winsSecondary;
}
outPar = moTarget.InvokeMethod("SetWINSServer", inPar, null);
}
return true;
}
catch
{
return false;
}
}
Now, my problem comes when the user wants to kill one the active servers. On server closure I have to remove from the NIC the IP address the server was listening to.
Killing the process it's not a problem, but when I call my ChangeNetworkInterfaceIPs to update the IP assigned to NIC (removing the one of the server no longer in use) using a new list of IP address (namely: the old list without the ip address of the killed server) something very strange happens: randomly some of other running servers get a SOCKET_ERROR and their connection it's closed.
Any idea on what's happening? Why the running servers are randomly getting SOCKET_ERRORs when I remove an unused IP address from the NIC ? Additionally, I know that probably setting a whole list of IP addresses just to remove one it's not really a best practice: is there a way to remove just a given IP address?
I hope the question is clear enough. Thank you for your time.
|
|
|
|
|
The problem occurs probably because the underlying code in the Win32_NetworkAdapterConfiguration class deletes all the IP's from the adapter and rewrites the list of IPs, or at least partially so.
Using WMI, there's nothing you can do about it. Also, the 3rd party server apparently isn't tolerant of the IP binding changing or disappearing for a brief time. There's nothing you can do about that either, except find another product.
One method I've used to get around screwy problems like this is to run this stuff in virtual machines, one server instance = one VM. If you need to change the IP or the server, mearly shutdown the VM, make any IP changes to it, reatart the VM and the server comes up not knowing anything happened.
|
|
|
|
|
thank you for you support Dave.
I came exactly to the same conclusion as well.
Sadly due several reason we cannot use VMs, so I'm still struggling in order to find a proper solution / work around.
Cheers
|
|
|
|
|
Hi all,
I want to create an application which detects the webcam to take the photos and this application should work on any platform,operating System.
Please can any one suggest me how can i start creating this application.
Thanks in advance
|
|
|
|
|