Ambiguous reference between X and Y problem

S

Simon

I am referencing the same class library in Web service and in application
and I get the ambiguous reference error.

How can I slove this problem?

Thank you

Simon
 
S

Simon

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";
}
}
}
 
P

Pipo

Rename one of the functions...
OR
Do in the usings
using TestApp
and prefix the call (WebService.ServiceTest serv;)
OR
using x = TestApp.WebService;
and then x.ServiceTest serv;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top