Click here to Skip to main content
15,066,928 members

Comments by Henry Hunt (Top 48 by date)

Henry Hunt 1-Jan-14 12:54pm View
I have looked online for ages but can't find anything that works. Most say that you should make sure this is in both the client and server applications:

[binding name="NetTcpBinding_IService1"]
[security mode="None"/]
...but I don't know where to put it in my host. I have tried and put it directly in the system.servicemodel section but I then get a CommunicationException so I don't know what to do.
Henry Hunt 1-Jan-14 10:11am View
Finally some help!! Yes...but I don't understand what you mean. Is it not able to log onto the host at the server?
Henry Hunt 1-Jan-14 9:45am View
Oh my god! I completely missed it ahaha. Thank you for that! It works perfectly now.
Henry Hunt 30-Dec-13 13:17pm View
Isn't there any way I can avoid using another thread? All I want to do is change the visibility of a control and wait for it to render before continuing, is it really that hard?!
Henry Hunt 29-Dec-13 14:33pm View
Reading this, am I right in thinking that http is not the right 'thing' to be using because it is not hosted on a website or intranet or online? Should I be using the netTcpBinding instead so I use 'net.tcp://' instead of 'http://'? Maybe that it why it is not working, because it thinks its a service or file on a website not an endpoint?
Henry Hunt 29-Dec-13 12:15pm View
I have not posted any code for the service, only the host console that uses it. This is the code for the client which is also a console:

static void Main(string[] args)
CalculatorClient client = new CalculatorClient();



double value1 = 100.00D;
double value2 = 15.99D;
double result = client.Add(value1, value2);
Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

value1 = 145.00D;
value2 = 76.54D;
result = client.Subtract(value1, value2);
Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);

value1 = 9.00D;
value2 = 81.25D;
result = client.Multiply(value1, value2);
Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);

value1 = 22.00D;
value2 = 7.00D;
result = client.Divide(value1, value2);
Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);


Right, all I basically want is to have a computer. This computer will be downloading data from the internet and saving it (that part has nothing to do with WCF) and it will also run the server software. There will be lots of people on separate computers with a piece of software that will use the service to send a code back to the server. The server will then read that code and select the relevant piece of data (which it downloaded previously) to send back to the client (whether it be an image file or just a value). It is simple and I have it working absolutely perfectly with the client and server on the same machine, it sends the data back just like I want but the error occurs whenever I try to run the client on another machine from the server and I assumed it is a problem with how I have configured both the server and client.
Henry Hunt 28-Dec-13 11:55am View
That is the bit I can never do with any success! How would I change this endpoint address to make it work on another machine: http://localhost:8000/SystemControllers/Administrator

Do I just have to change 'localhost:8000' to the IP address of the machine that is running the client? I don't understand this part.
Henry Hunt 28-Dec-13 9:36am View
Oh, so all I have to do is change the endpoint URLs so that they are not localhosts and make sure all clients use the same URL as the host?
Henry Hunt 20-Dec-13 10:48am View
Great, worked perfectly! Thank you.
Henry Hunt 16-Dec-13 11:02am View
Ah I get you, yes it may be useful. All I really want is a list of URLs to all of the pages belonging to a website/server/domain
Henry Hunt 16-Dec-13 11:00am View
Ah I get you, yes it may be useful. All I really want is a list of URLs to all of the pages belonging to a website/server/domain
Henry Hunt 16-Dec-13 10:57am View
Sorry, what do you mean by that?
Henry Hunt 30-Nov-13 7:26am View
I've got it, it works now. I had to do DataContext = this and a few other things when updating the listview so there are now no references to the listview control itself. Thank you!
Henry Hunt 30-Nov-13 5:01am View
Does the XAML affect how the list reloads? Because I am still getting a NullReferenceException. I have pasted your C# code as it is without changing anything and am using this to control the items in it:

timeSteps.ItemsSource = null;

XmlDocument capabilities = new XmlDocument();
List<timestep> timesteps = new List<timestep>();
List<string> timeList = new List<string>();
List<timestep> reloading = new List<timestep>();

"" +
UserProfile.Read.ApiKey(), DateTime.Now.Second.ToString()));

for (int x = 0; x < capabilities.SelectNodes("//Layer[@displayName='Rainfall']/Service/Times/Time").Count; x++)

foreach (string s in timeList)
TimeStepDataCollection.Add(new TimeStepData() {
TimeStepItem1 = (DateTime.Parse(s.Remove(10).Replace("-", "/")).ToString("dd/MM/yyyy") +
" at " + s.Remove(0, 11).Remove(5)) + ":00", TimeStepItem2 = s });
new Global().UpdateDataTree(set: "Observation Maps", entry: "Rainfall Rate",
step: timeList.ToArray(), type: "Observation", freq: "15 Minutes", dist:
"Met Office", serv: "OBSERVATION", unit: "mm/h (millimetres per hour)", key: "true");

timeSteps.ItemsSource = TimeStepDataCollection;

Maybe I am doing it wrong?
Henry Hunt 30-Nov-13 4:48am View
Thank you so much!! That has helped me finish quite a few parts of my application. :)
Henry Hunt 29-Nov-13 14:54pm View
How would I implement the observable collection? I have looked on the internet for observable collections and listviews but cannot get anything to work
Henry Hunt 15-Nov-13 16:00pm View
This works, thank you but where would I write my main code to do things like actually download the data? I'm a bit confused as to which classes do what
Henry Hunt 15-Nov-13 15:43pm View
THAT'S IT!! That's what I want, like a list<>
Henry Hunt 12-Nov-13 3:00am View
Ahhh I get it now... So I should just change the event args in the method to something like MouseEventArgs and add it as a handler to the ListView?
Henry Hunt 11-Nov-13 13:43pm View
But that's the problem...I don't know how to use the method from that post: I mean you can't exactly go statusLabel.Content = new GlobalClasses().UpdateStatus(*** This is the bit I don't get. what do I do with this bit: DragEventArgs?***) or can you? That is what I want to know. I have never come across 'functions' with events in them apart from the obvious event handlers for controls but I wouldn't class that as a 'function' that I have written.
Henry Hunt 11-Nov-13 12:55pm View
OK...I have found this code below:
private ListViewItem FindListViewItem(DragEventArgs e)
var visualHitTest = VisualTreeHelper.HitTest(dataTree, e.GetPosition(dataTree)).VisualHit;
ListViewItem listViewItem = null;
while (visualHitTest != null)
if (visualHitTest is ListViewItem)
listViewItem = visualHitTest as ListViewItem;
else if (visualHitTest == dataTree)
MessageBox.Show("Found ListView instance");
return null;
visualHitTest = VisualTreeHelper.GetParent(visualHitTest);
return listViewItem;
...but I don't know how to use/call it because of the event in the parameters. Do I haver to attach it to an event in my ListView to use it or what? It was from here:
Henry Hunt 9-Nov-13 12:28pm View
But it doesn't work like that for a ListView item. Don't you have to determine the current pointer location and then get the item under it or something? That is the part I cannot do.
Henry Hunt 5-Nov-13 14:04pm View
Ok thank you, I will have another go at writing thing though: would this be a DateTime or an int?: nextExpected = time() + updateRate, and is time() just the current time?
Henry Hunt 25-Oct-13 14:25pm View
As you said this code does work but it limits me to what I can do as I cannot use this code with the 'System.Windows' and 'System.Drawing' namespaces both referenced as I get the ambiguity error between the point definition, that was why I needed a 'conversion'
Henry Hunt 23-Oct-13 15:05pm View
Yes, from a url and save it to the disk
Henry Hunt 21-Oct-13 13:46pm View
Perfect! Thank you
Henry Hunt 19-Oct-13 5:15am View
Thank you, I have accepted it. Just out of interest, would you say that WCF is the right way to go to match login details with a database on another computer when someone logs in or is there a better way?
Henry Hunt 18-Oct-13 12:55pm View
ah ok...What I am trying to do is when someone signs in or fills in details to request an account it encrypts the entered data and sends it using WCF to another computer containing a database of accounts which it then decrypts the sent data and cross matches it with the database to get a correct login and then sends a message back saying it can log in. Just to make sure you know what context I want to use the encryption in. Another thing: I am amazed at how much knowledge you have about not just C# but lots of other languages and computers and encryption and a lot about everything to do with computer programming. Where and how have you got it all from?!
Henry Hunt 18-Oct-13 12:23pm View
By huge I mean hundreds or thousands of characters and the purpose is that the number is a sequence of characters from encryption I have made where it converts inputted characters to their ascii codes and does some other stuff with it to make it 'secure'. I know it sounds like a crazy idea and that it could be cracked maybe quite easily but still...
Henry Hunt 18-Oct-13 12:22pm View
By huge I mean hundreds or thousands of characters and the purpose is that the number is an encryption I have made where it converts inputted characters to their ascii codes and does some other stuff with it to make it 'secure'.
Henry Hunt 18-Oct-13 12:19pm View
Thank you I will have a go at that. It is annoying because I don't actually need the number to do any maths on, I only need it to stand in as a very, very long sequence of numbers.
Henry Hunt 16-Oct-13 3:00am View
In both errors, it is when I load the XmlDocument capabilities with either a local file or a file on the web. So it is when I request it I suppose.

Loading a file from the web: Request for the permission of type 'System.Net.WebPermission, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Loading a local file: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Henry Hunt 16-Oct-13 2:44am View
Nope same error when I save it to the disk and use that instead. Is it something to do with the security rights of the application or code? But this time it is a request for a FileIOPermission not a web one I just noticed.
Henry Hunt 4-Oct-13 14:43pm View
Thank you for this, it helped but the code with the error is always in the automatically generated code by the designer to store all of the properties for the controls I have on the form and not code that I have written so I really don't know how to solve it.
Henry Hunt 4-Oct-13 11:01am View
Yes, completely fine. Then I saved and closed and turned off my computer. Had my day and come back to find it starts to throw errors
Henry Hunt 4-Oct-13 10:54am View
- I can't see any memory usage problems and I don't have much open

Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel
Microsoft .NET Framework
Version 4.5.50709 SP1Rel
Installed Version: C# Express
- Windows 8 64bit
Henry Hunt 8-Sep-13 12:08pm View
Hello again, I have just one more thing for you. How would I reference to a specific 'set' of elements depending on on of the containing element values instead of the attribute at the top of the 'set' of elements. For example: The code I want to read is below. How would I get the Risk level from specifying the Area element?

How would I get the risk level for the Area value of East Highland? I don't want to use indexing, ie: using SelectNodes("")[n].innerText as the 'sets' of MountainForecast elements could be in a different order Thank you.

Area/Brecon Beacons/Area
Area/East Highland/Area

Had to remove the tag start and ends so hope you can read it, I put / between element and its value.
Henry Hunt 6-Sep-13 15:09pm View
Thank you, that worked.
Henry Hunt 6-Sep-13 14:46pm View
Thank you...I now have this code but there is a problem:

int minutes = Convert.ToInt16(DateTime.Parse("2013-09-05T14:00:00").ToString("mm"));
int hours = Convert.ToInt16(DateTime.Parse("2013-09-05T14:00:00").ToString("HH"));

TimeSpan mySpan = new TimeSpan(minutes, hours, 0);

int totalSecondsSinceMidnight = Convert.ToInt32(mySpan.TotalMinutes);

It returns 14 and there surely aren't 14 minutes since midnight are there? Could you work out why this is? Thank you.
Henry Hunt 6-Sep-13 12:01pm View
Does this work with attributes in the same way?
Henry Hunt 4-Sep-13 14:08pm View
But surely if I have 24 individual labels and I want each one to contain a different value from a different attribute from the same document and I don't want to use any type of list controls then that is how to do it? I can't think of any other way to populate different labels with different values other than one by one.
Henry Hunt 29-Aug-13 13:23pm View
I think I jump to asking for help after not trying for long enough myself! Solved it myself with this code:

static void Main(string[] args)
XmlDocument SiteList = new XmlDocument();
List<string> FinalList = new List<string>();
for (int x = 0; x < SiteList.SelectNodes("/Locations/Location/@id").Count; x++)
for (x = 0; x < SiteList.SelectNodes("/Locations/Location/@latitude").Count; x++)
for (x = 0; x < SiteList.SelectNodes("/Locations/Location/@longitude").Count; x++)
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("ID: " + SiteList.SelectNodes("Locations/Location/@id")[x].InnerText);
Console.WriteLine("LA: " + SiteList.SelectNodes("/Locations/Location/@latitude")[x].InnerText);
Console.WriteLine("LO: " + SiteList.SelectNodes("/Locations/Location/@longitude")[x].InnerText);
Console.WriteLine("HF: " + Haversine.Formula(Convert.ToDouble(Properties.Settings.Default.LATITUDE), Convert.ToDouble(Properties.Settings.Default.LONGITUDE), Convert.ToDouble(SiteList.SelectNodes("/Locations/Location/@latitude")[x].InnerText), Convert.ToDouble(SiteList.SelectNodes("/Locations/Location/@longitude")[x].InnerText)));
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("AL: " + Haversine.Formula(Convert.ToDouble(Properties.Settings.Default.LATITUDE), Convert.ToDouble(Properties.Settings.Default.LONGITUDE), Convert.ToDouble(SiteList.SelectNodes("/Locations/Location/@latitude")[x].InnerText), Convert.ToDouble(SiteList.SelectNodes("/Locations/Location/@longitude")[x].InnerText)) + "---" + SiteList.SelectNodes("/Locations/Location/@id")[x].InnerText);
FinalList.Add(Convert.ToString(Haversine.Formula(Convert.ToDouble(Properties.Settings.Default.LATITUDE), Convert.ToDouble(Properties.Settings.Default.LONGITUDE), Convert.ToDouble(SiteList.SelectNodes("/Locations/Location/@latitude")[x].InnerText), Convert.ToDouble(SiteList.SelectNodes("/Locations/Location/@longitude")[x].InnerText)) + "---" + SiteList.SelectNodes("/Locations/Location/@id")[x].InnerText));
foreach (object o in FinalList)
Henry Hunt 29-Aug-13 11:49am View
Doesn't work because the y loop follows on from the x loop. After getting the longs using x it then gets the lats with y using x to tell it to count up the same amount as it did to get the longs if that makes any sense.
Henry Hunt 19-Aug-13 5:22am View
I have just solved it myself with

if (Properties.Settings.Default.FirstRun == true)
APIKey APIKey = new APIKey();
MAIN_WeatherWatcher MAIN_WeatherWatcher = new MAIN_WeatherWatcher();
Henry Hunt 18-Aug-13 19:01pm View
I've tried doing 'Application.Run()' and then doing an if statement to check of the setting is true or false and telling it to show the first form if it is true and the second if it is false but that didn't work.
Henry Hunt 18-Aug-13 18:52pm View
Oh I mean open or show it
Henry Hunt 7-Aug-13 6:53am View
Another thing, how would I read an attribute and put it into a string for use in a URL? For example, how would I read the attribute value for 'displayName' in the SatelliteVis layer and store it in a string? Thanks.
Henry Hunt 6-Aug-13 12:44pm View
Thank you so much, it worked great after a few changes. One more thing, it returns the whole element (e.g: 'time 2013-08-06T15:00:00 /time' is there a way to just get the data inside the tags or would I just use replace to replace the 2 tags either side of the data with an empty space?