Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Ambiguous reference between X and Y problem

Reply
Thread Tools

Ambiguous reference between X and Y problem

 
 
Simon
Guest
Posts: n/a
 
      03-14-2009
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

 
Reply With Quote
 
 
 
 
Simon
Guest
Posts: n/a
 
      03-16-2009
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";
}
}
}

 
Reply With Quote
 
 
 
 
Pipo
Guest
Posts: n/a
 
      03-18-2009
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;


"Simon" <> wrote in message
news:6721D060-0F85-47D6-B66D-...
> 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";
> }
> }
> }



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler bug? "reference to addAll is ambiguous" Oliver Wong Java 15 07-21-2007 09:15 AM
Ambiguous reference to type `UNSIGNED' - How to deal with this issue? zhaoxiang.99@gmail.com VHDL 3 01-10-2007 11:29 AM
Ambiguous reference to type jahaya@gmail.com VHDL 2 09-12-2005 09:55 AM
newbie: "reference to object is ambiguous" error LaCo Java 5 05-13-2004 08:00 PM
ambiguous reference and inheritance zoe Java 14 12-18-2003 04:54 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57