 |
BOOK: Beginning Visual C# 2010
 | This is the forum to discuss the Wrox book Beginning Visual C# 2010 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, ; ISBN: 9780470502266 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning Visual C# 2010 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 22nd, 2011, 02:45 PM
|
|
Registered User
|
|
Join Date: May 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
ch 19 adding windows Form to
in chapter 19 try out("Creating a Client Windows Application),
I can not add a windows form application to the WebServiceSample
project, because it doesn't show in the adding new item list.
anyone knows why...?
|
|

July 7th, 2011, 05:41 PM
|
|
Wrox Author
|
|
Join Date: Sep 2010
Posts: 175
Thanks: 3
Thanked 53 Times in 53 Posts
|
|
You need to do a "add new project" while selecting the solution inside the solution explorer instead of "add new item" while selecting the project
Hope this helps.
|
|
The Following User Says Thank You to ChristianNagel For This Useful Post:
|
|
|

December 8th, 2011, 11:33 AM
|
|
Authorized User
|
|
Join Date: Dec 2011
Posts: 23
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
VCE
Quote:
Originally Posted by ChristianNagel
You need to do a "add new project" while selecting the solution inside the solution explorer instead of "add new item" while selecting the project
Hope this helps.
|
In VCE all I get is "Class" - no option to create a Form. Am I doing this right? Can this be done in VCE?
|
|

December 8th, 2011, 12:03 PM
|
|
Authorized User
|
|
Join Date: Dec 2011
Posts: 23
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
I wound up deploying the webservice on my local drive and referencing the local host address in the webform. In so doing I discovered that on page 66 number 4 it should read
void client_ReverseStringCompleted(object sender, WebServicesSample.ReverseStringCompletedEventArgs e)
The WebServicesSample is missing in the text.
|
|

December 9th, 2011, 11:13 AM
|
|
Authorized User
|
|
Join Date: Nov 2011
Posts: 34
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
I have problem with that try out:
Code compiles, in windows forms,text2.text gives reversed string,as expected,but then throws exception:
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var client = new ServiceReference1.sampleserviceSoapClient();
textBox2.Text = client.reversestring(textBox1.Text);
client.reversestringCompleted += client_ReverseStringCompleted;
client.reversestringAsync(textBox1.Text);
}
void client_ReverseStringCompleted(object sender, reversestringCompletedEventArgs e)
{
if (e.Error != null)
{
textBox2.Text = e.Result;
}
else
{
MessageBox.Show(e.Error.Message);
}
}
}
}
System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=WindowsFormsApplication1
StackTrace:
at WindowsFormsApplication1.Form1.client_ReverseStrin gCompleted(Object sender, reversestringCompletedEventArgs e) in C:\Users\administrator\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.cs:line 36
at WindowsFormsApplication1.ServiceReference1.samples erviceSoapClient.OnreversestringCompleted(Object state) in C:\Users\administrator\AppData\Local\Temporary Projects\WindowsFormsApplication1\Service References\ServiceReference1\Reference.cs:line 201
InnerException:
This only happens when i call Service Asynchronously,try it out on page 651 works fine.
@Frodo,i am using VCE,when you create service,you must launch Microsoft Visual c# Express 2010,create new windows form and add service reference,of course Microsoft Visual Web Developer 2010 Express must remain open.I hope this helps.
Last edited by dampyr; December 9th, 2011 at 11:19 AM..
Reason: adding
|
|

December 13th, 2011, 06:41 PM
|
|
Wrox Author
|
|
Join Date: Sep 2010
Posts: 175
Thanks: 3
Thanked 53 Times in 53 Posts
|
|
@dampyr,
you need to change the if statement in the event handler. If there's not an error the textBox2.Text result should be filled, otherwise the error message should be shown. In the original case the else part was only accessed when e.Error was null, and of course if there the Message property is accessed a null reference exception is thrown.
Code:
if (e.Error == null)
{
textBox2.Text = e.Result;
}
else
{
MessageBox.Show(e.Error.Message);
}
|
|
The Following User Says Thank You to ChristianNagel For This Useful Post:
|
|
|
 |
|