Follow up on this question with some code. I get errors:
Error 1 'TestName' is an ambiguous reference between 'TestClass.TestName'
and 'TestApp.WebService.TestName' C:\NET\TestWeb\TestApp\Form1.cs 23 13
TestApp
This is the problem, because I would like to use the same class in both web
service and application. How can I avoid this?
Thank you for your help
Simon
*** Appliation that references web service and class library:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TestClass;
using TestApp.WebService;
namespace TestApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
TestName name;
ServiceTest serv;
name.Name = this.textBox1.Text;
serv = new ServiceTest();
serv.Test1(name);
this.textBox2.Text = name.Name;
}
}
}
*** Class library:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestClass
{
public class TestName
{
public TestName()
{
Name = "";
}
public String Name
{
get;
set;
}
}
}
*** And web service that also references class library:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using TestClass;
namespace TestService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "
http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET
AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class ServiceTest : System.Web.Services.WebService
{
[WebMethod]
public void Test1(TestName test)
{
test.Name += " CHECKED";
}
[WebMethod]
public void Test2(TestName test)
{
test.Name += " CHECKED";
}
}
}