0

I created a web app in which I am using WCF service,

when I build my project and run, the method in my WCF service getting executed 2 times for the first time only but after that it works normally,

here is my code,

FileInfo fi = new FileInfo(destFileName);
FileServer.ServiceClient fs = new FileServer.ServiceClient();
FileServer.RemoteFileInfo uploadRequestInfo = new FileServer.RemoteFileInfo();
using (System.IO.FileStream stream = new System.IO.FileStream(fi.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
    uploadRequestInfo.FileServerId = item.FileServerId;
    uploadRequestInfo.FileName = item.FileName;
    uploadRequestInfo.FileExtension = item.FileExtension;
    uploadRequestInfo.Length = fi.Length;
    uploadRequestInfo.FileByteStream = stream;
    fs.UploadFileStream(uploadRequestInfo.FileExtension, uploadRequestInfo.FileName, uploadRequestInfo.FileServerId, uploadRequestInfo.Length, stream);
}

my reference.cs class

    [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
    DocPro.DMS.WebApp.FileServer.UploadFileStreamResponse DocPro.DMS.WebApp.FileServer.IService.UploadFileStream(DocPro.DMS.WebApp.FileServer.RemoteFileInfo request) {
        return base.Channel.UploadFileStream(request);
    }
    
    public void UploadFileStream(string FileExtension, string FileName, string FileServerId, long Length, System.IO.Stream FileByteStream) {
        DocPro.DMS.WebApp.FileServer.RemoteFileInfo inValue = new DocPro.DMS.WebApp.FileServer.RemoteFileInfo();
        inValue.FileExtension = FileExtension;
        inValue.FileName = FileName;
        inValue.FileServerId = FileServerId;
        inValue.Length = Length;
        inValue.FileByteStream = FileByteStream;
        DocPro.DMS.WebApp.FileServer.UploadFileStreamResponse retVal = ((DocPro.DMS.WebApp.FileServer.IService)(this)).UploadFileStream(inValue);
    }

I used WCF service reference in my project,

is there anything wrong with my code, I saw multiple questions on stackoverflow about this but didn't find any solution,

here are few article which I saw,

WCF Completed Event is getting called multiple times

WCF service method called twice

Static constructor called twice for PerSession WCF service

Ibrahim shaikh
  • 235
  • 2
  • 15

1 Answers1

0

this has been fixed, actually the problem was with my front-end as I am calling 2 different controller from javascript which is calling same WCF method

Ibrahim shaikh
  • 235
  • 2
  • 15
  • Please provide additional details in your answer. As it's currently written, it's hard to understand your solution. – Community Aug 30 '21 at 11:41