sarah sh
sarah sh

Reputation: 315

how to specify the assembly explicity in the type name?

I am using the visual studio 2010 for designing a web,and I have used the layer

programming,I am using a gidview and objectdatasource, but I get this exeption:

"The type 'WebApplication4.view1' is ambiguous: it could come from assembly   
 'C:\Users\EHSAN\AppData\Local\Temp\Temporary ASP.NET 
  Files\root\d04444bc\d654bde6\App_Code.i0fp6yrj.DLL' or from assembly 
  'C:\Users\EHSAN\Documents\Visual Studio 
  2010\Projects\WebApplication4\WebApplication4\bin\WebApplication4.DLL'. Please 
  specify the assembly explicitly in the type name."

I put my code here:

this is my web.aspx:

<asp:ObjectDataSource ID="ObjectDataSource1" Runat="server" TypeName="WebApplication4.view1"
        SelectMethod="Search" OldValuesParameterFormatString="original_{0}" >

      </asp:ObjectDataSource>

and this is the search.cs file in BAL folder in APP_Code:

namespace WebApplication4
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Linq;
    using System.Data;
 public class view1 : System.Web.UI.Page
    {
        public view1()
        { }

        public List<person> Search()
        {
            List<person> persons = new List<person>();
            DataSet ds = PersonsDB.Search();

            foreach (DataRow row in ds.Tables[0].Rows)
            {

                persons.Add(new person((String)row["id"], (String)row["nam"], (String)row["family"], (String)row["namepedar"], (String)row["shshenas"], (String)row["codemelli"]));
            }


            return persons;
        }
    }

where is the problem?

Upvotes: 7

Views: 14251

Answers (6)

Bloopy
Bloopy

Reputation: 429

In my case I have a parent and child web site sharing the same master page. I got this error when I mistakenly put a copy of the child web site's DLL file in the bin folder of the parent web site. So it is indeed a matter of making sure no extra DLL files are hanging around unnecessarily.

Upvotes: 0

Nisha
Nisha

Reputation: 1439

Right click the website/web application property and set Assembly name field with the intended name.

Eg: If the application is named as XYZ and uses namespace naming as companyname.dept.XYZ then the application may have 2 separate dlls. XYZ.dll and companyname.dept.XYZ.dll which can cause conflicts.

Upvotes: 0

Mahesh Kumar
Mahesh Kumar

Reputation: 9

When you add a reference to the solution, please make that file properties copy to local to "False". So it will not get copied when we build the solution and we will not get the error. It works for me. please try this.

Upvotes: 0

lapers
lapers

Reputation: 31

I had the same error. I created WebUserControl project with control in it named control1. Also I had project Website1 where I used my control1(using project build event to copy control1 to Website1). It worked fine, but then I copied my Website1 project and renamed as Website2 project. On website2 I got this error. Clean, rebuild did not solve. I deleted all files in Website2\bin folder and build Website2 project. Error was solved.

Upvotes: 3

Farax
Farax

Reputation: 1477

Try moving the Search.cs file out of the App_Code folder and see if it works. I had the same problem and I moved it out and it started to work.

Upvotes: 12

Augusto
Augusto

Reputation: 151

This happens when there are two classes with the same name in the project, usually due to a copy and paste error. Can you check if you have any other class named view1 elsewhere?

If this is not the problem, try to clear up your temporary web files, as shown here: Clearing out temporary asp.net files

Upvotes: 2

Related Questions