Why is there a two-dimensional type error when calling WebMethod in an ASP.NET web application?

The message sent to the browser is as follows:

The type My.API.Class is ambiguous: it can be obtained from the assembly '[on temporary ASP.NET files]' or from the assembly '[in the bin folder]'

The problem occurs when debugging a web application, especially when accessing WebMethod WebService.

The project is running correctly. He creates My.Website.dll in the bin folder and published the web application. It works great.

The asmx file is at the root of the application. The CodeBehind file is located on App_Code and is marked for compilation to create My.Website.dll.

I need to miss something really important.

I found that someone has the same problem with a possible related cause. Check it out . The way this person reveals his problem is somehow similar, but I start to get lost when he talks about the proxy class and common DLLs that I do not use.

Any help is appreciated.

+3
source share
3 answers

According to this , the App_Code folder should only be used in website projects. This is the reason CodeBehind asmx was compiled at runtime.

The initial question was made based on a web application. But I did not specify this web application. was manually changed from the website project.

To solve my problem, I did the following:

  • -. , App_Code Old_App_Code.
  • Old_App_Code , -.

@: , .

+6

- "" "- > " Visual Studio. . , My.API.Class . dll ( , ). , My.API, , .

+2

, "" ex:

<%@ WebService  Language="C#" CodeBehind="~/App_Code/WebService.cs"  Class="WebService" %>

<%@ WebService  Language="C#"  Class="WebService, YourProjectName" %>

-, - , "App_Code", -, "YourProjectName".

, , , ( ).

0

Source: https://habr.com/ru/post/1795806/


All Articles