Archive for October, 2008

.NET (C#) Multiple Monitors

October 14, 2008
Dear Diary
 
Another achievemet today was to get .NET forms to display in the second monitor if available.
This is useful for development because normally use large monitor for coding but want running app in second monitor.
 
The key is to get the virtaul desktop parameters and set the form left and top to this.
 
Even did an animation version wher it glides across.  Cool.
 
Next to do would be spiralling in, blinds etc like in Powerpoint!
 

ASPX Page Communicating with Windows Form via WebService

October 14, 2008
Dear Diary
 
Previous achievement was to get a Windows Form to launch a menu on a .ASPX page such that the menu list was supplied via a web service on the website.
The list can be bigger tha the number of items to displayed.
It breaks the list into ranges and so you drill down, viz browsing up and down a long list.
 
Query parameters action menu selction for drilling into the existing list, next and previous for moving across subranges , restart etc.
 
Today’s achievement was to get the website to process  menu selction ,  when the final item is selected and signal the web form.
This is done using an ansychronous web method call.
ie using Begin and End calls to the web method.
 
I had two problems.
– I was using ViewState to maintain variable state in a class for .aspx pages.
  It seems though that when you put a parameter on the URL a new ViewState is used and so the  information is lost ???
  Solution : Save the class instance to the Session under a key derived from the .aspx filename
  Get it back when the .aspx page is loaded; if null craete a new class instance.
– I first developed a class to handle the Asynch call as separate project..
  I ran this as an app with Main method.
  This had a Sevice Reference to the webservice, like the Form to be used… But different name
  I then chnged it to be a  (ie .DLL) and include it in the overall app as a sub project and referenced by the Form project
  It wouldn’t work.  Kept getting an error when tring to instantiate the web service.
 
eg Getting an error Could not find default endpoint element that references contract ‘IInterfaceName"
"Could not find default endpoint element that references contract ‘IInterfaceName" in the service model client configuaration section.
This might be because no configuaration file was found for your application or because no end point element matching this contract could be found in the client element
"
 
It eventuially dawned that it was probably just a web reference issue.
 
I dragged the class file into the Form project and referenced it from there in the form.
That worked.
 
Reason: It seems that the service reference belows to the apllication as correpondence wa sugesting to put the service info. in the app.config file.

Your client is looking for an endpoint definition in its config file. It should look something like this:

 <system.serviceModel>
<client>
<endpoint name="InterfaceName" address="
http://yourserver/InterfaceName.svc" binding="wsHttpBinding" contract="IInterfaceName"/>
</client>
</system.serviceModel>

 
Wala!
 
 
 
 
 

Vista: localhost problem

October 1, 2008
Situation: Vista Ultimate, Problem using localhost as target, eg in browser with Personal Firewall on (Eset Smart Securoty).
 
With a Persnal Firewall turned on I get a problem accessing local host:
With GPSGate when I enable view in browser it says to look at the content at http://localhost:12175
 
– With the PFW off this works
– With it on it doesn’t but http://127.0.0.1:12175 does
 
With PFW on:
If I ping 127.0.0.1 I get normal ping information.
If I ping localhost you get reduced info and that its using ::1. 
 
This means that Vista is defaulting to IPV6
 
Look at hosts file in C:\Windows\System32\drivers\etc
(Run notepad in adminstrator mode, change to *.*).
Two entries at bottom:
 
127.0.0.1       localhost
::1             localhost
 
If you remove the last one then pinging worls as with 127.0.0.1 and access to localhost as tried above works.
(I ended up commenting it out with a #).
 Cheers