WCF方法从Java脚本/Ajax多次调用 [英] WCF method calling multiple times from java script/Ajax

查看:53
本文介绍了WCF方法从Java脚本/Ajax多次调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1. 大家好,
在更改或修改数据访问层中的某些内容时,出现以下提到的错误.

1.无法将文件"C:\ bin \ Debug \ ajaxservice.Data.dll"复制到"bin \ Debug \ ajaxservice.Data.dll".该进程无法访问文件"bin \ Debug \ ajaxservice.Data.dll",因为它正在被另一个进程使用. ajaxservice.Services

2.无法将文件"C:\ bin \ Debug \ ajaxservice.Business.dll"复制到"bin \ Debug \ ajaxservice.Business.dll".该进程无法访问文件"bin \ Debug \ ajaxservice.Business.dll",因为该文件正在被另一个进程使用. ajaxservice.Services
重新启动系统后,该错误不会再出现,但是我遇到方法调用两次问题.
(实际上,我是从Java脚本中调用某些WCF方法,而直接从C#中调用某些方法.方法是从Java脚本中调用时多次调用.如果我从C#中调用,则相同的方法也可以正常工作.请帮助我解决此问题.)
var service = new Hotal.Services.IMenuSearchService();
service.FindRestaurant(City, Area, onRestaurantSeachSuccess, onRestaurantSeachFailed, null);

以下方法仅调用两次:


public IEnumerable<Data.NewRestaurantHeader> FindRestaurant(string City, string Area)
        {
            Business.Menu menu = new Business.Menu();
            return menu.FindRestaurant(City, Area);
        }



public IEnumerable<Data.NewRestaurantHeader> FindRestaurant(string City, string Area)
        {
            // LinQ query here
        }





2.我正在从Java脚本中调用某些WCF方法,而直接从C#中调用某些方法.每当从Java脚本调用时,方法都会多次调用.如果我从C#调用,则相同的方法也可以正常工作.请帮助我解决此问题.)

var service = new ajax.Services.IMenuSearchService();<br />
service.FindRestaurant(City, Area, onRestaurantSeachSuccess, onRestaurantSeachFailed, null);



以下方法仅调用两次:

public IEnumerable<Data.NewRestaurantHeader> FindRestaurant(string City, string Area)
        {
            Businesslayer menu = new Businesslayer ();
            return menu.FindRestaurant(City, Area);
        }




public IEnumerable<Data.NewRestaurantHeader> FindRestaurant(string City, string Area)
       {
           // LinQ query here
       }



3.从Windows Server 2008 + IIS 7运行时,两次调用wcf方法,但是如果我从本地运行,则一切正常.

解决方案

您的问题的解决方案无法复制文件...."是您需要关闭Visual Studio解决方案并从项目中删除bin/debug或bin/release中生成的所有dll.然后打开Visual Studio,打开解决方案并重新构建.会很好用的.

永久的解决方案是删除解决方案中所有项目的bin文件夹上的只读属性.


WCF服务被调用两次是因为消息的大小大于默认消息的大小.您可以尝试在端点的配置中增加此值

1. Hi All,
while I change or modify something in data access layer, I am getting below mentioned error.

1. Unable to copy file "C:\bin\Debug\ajaxservice.Data.dll" to "bin\Debug\ajaxservice.Data.dll". The process cannot access the file ''bin\Debug\ajaxservice.Data.dll'' because it is being used by another process. ajaxservice.Services

2. Unable to copy file "C:\bin\Debug\ajaxservice.Business.dll" to "bin\Debug\ajaxservice.Business.dll". The process cannot access the file ''bin\Debug\ajaxservice.Business.dll'' because it is being used by another process. ajaxservice.Services
After I restarting the system the error will not be again but I am getting method calling twice problem.
(Actually I am calling some WCF method from java script and some directly from C#. The menthod is calling multiple times whenever calling from java script. If I call from C#, the same methods working fine. Please help me how to fix this.)
var service = new Hotal.Services.IMenuSearchService();
service.FindRestaurant(City, Area, onRestaurantSeachSuccess, onRestaurantSeachFailed, null);

the below method only calling twice:


public IEnumerable<Data.NewRestaurantHeader> FindRestaurant(string City, string Area)
        {
            Business.Menu menu = new Business.Menu();
            return menu.FindRestaurant(City, Area);
        }



public IEnumerable<Data.NewRestaurantHeader> FindRestaurant(string City, string Area)
        {
            // LinQ query here
        }





2. I am calling some WCF method from java script and some directly from C#. The menthod is calling multiple times whenever calling from java script. If I call from C#, the same methods working fine. Please help me how to fix this.)

var service = new ajax.Services.IMenuSearchService();<br />
service.FindRestaurant(City, Area, onRestaurantSeachSuccess, onRestaurantSeachFailed, null);



the below method only calling twice:

public IEnumerable<Data.NewRestaurantHeader> FindRestaurant(string City, string Area)
        {
            Businesslayer menu = new Businesslayer ();
            return menu.FindRestaurant(City, Area);
        }




public IEnumerable<Data.NewRestaurantHeader> FindRestaurant(string City, string Area)
       {
           // LinQ query here
       }



3. The wcf method calling twice while running from windows server 2008 + IIS 7 but if I run from local are all working fine.

解决方案

The solution to your problem "Unable to copy file ...." is that you need to close your visual studio solution and delete all the dlls generated in bin/debug or bin/release from the project. Then open the visual studio, open the solution and build it again. It will work fine.

The permanent solution for this will be to remove the read-only attributes on the bin folders for all projects in the solution.


The WCF service is called twice be because the size of the message is greater than the default message size. You might try increasing the this value in the configuration of the endpoint


这篇关于WCF方法从Java脚本/Ajax多次调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆