locked
System.IO.FileNotFoundException RRS feed

  • Question

  • User-1852975005 posted

    Hi, I am attempting to run the code below in a console app.
    It compiles, but has an error when run. VS2019.

    using SoapClnt;

    <div>object[] obj;</div> <div>            SoapClnt.WebRefSCX.SCXService MySoap;</div> <div>            //InitializeComponent();</div> <div>            MySoap = new SoapClnt.WebRefSCX.SCXService();</div> <div>            //StartSoap();</div> <div> </div> <div>            MySoap.Url = "http://localhost/webservices/scx";</div> <div> </div> <div>            obj = new object[0];</div> <div>            object[][] retobj;</div> <div>            bool limit;</div> <div>            retobj = MySoap.ExecuteQuery("Select CurrentValueFormatted from CDBPoint where FullName=New Analog Point", obj, out limit);</div> <div> </div> <div>            //for (int i = 0; i < retobj.Length; i++)</div> <div> </div> <div>            //Console.WriteLine(retobj[i][0].ToString());</div> <div> </div> <div>            Console.WriteLine(retobj);</div> <div>            Console.ReadKey();</div> <div></div> <div></div> <div>Error</div> <div></div> <div>

    <div>System.IO.FileNotFoundException</div> <div>  HResult=0x80070002</div> <div>  Message=Could not load file or assembly 'Web References.WebRefSCX.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.</div> <div>  Source=<Cannot evaluate the exception source></div> <div>  StackTrace:</div> <div><Cannot evaluate the exception stack trace></div> <div></div> </div> <div></div> <div></div> <div></div>

    However WebRefSCX seems to be referenced.

    Tuesday, March 17, 2020 6:02 AM

Answers

  • User-1852975005 posted

    Hi, I started from scratch again. This time bringing code in from the opposite way around, program b into program a (and it seems to be working).

    Two errors

    Client.RemoteCertificateValidationCallback

    RestClient does not contain definition RemoteCertificateValidationCallback

    -----------------------------------------------------------------------------------

    request.AddJsonBody

    RestRequest does not contain definition AddJsonBody

    -----------------------------------------------------------------------------------

    I had to update the version of RestClient to suit the framework. So I am guessing definition names have changed?

    Thanks,

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 26, 2020 10:22 PM

All replies

  • User-1605831695 posted

    Hi Mate,

    Web References.WebRefSCX by reinstalling from NuGet package, which corrects broken dependencies. From the package manager, run:

    Tuesday, March 17, 2020 9:24 AM
  • User-1852975005 posted

    Sorry Guy's, I have tried what you have suggested.

    I noticed that the error message says Version=0.0.0.0?

    Web References.WebRefSCX.Reference.cs.dll is under Assemblies and no errors seem to be indicated, in the properties it does not show a version number.

    Exception shown below;
    System.IO.FileNotFoundException
      HResult=0x80070002
      Message=Could not load file or assembly 'Web References.WebRefSCX.Reference.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
      Source=<Cannot evaluate the exception source>
      StackTrace:
    <Cannot evaluate the exception stack trace>
    Wednesday, March 18, 2020 6:28 AM
  • User-1852975005 posted

    Web References.WebRefSCX by reinstalling from NuGet package, which corrects broken dependencies. From the package manager, run:

    How do I do that, I am not sure I am doing it right

    It also has an error with using SoapClnt;

    Thursday, March 19, 2020 6:27 AM
  • User-1852975005 posted

    Web Reference option is greyed out on right click menu

    Is it due to the type of project I am trying to move the code into, what type should it be?

    I am merging a soap program into a rest client program. As I need to be able to use both in the same application.

    Message below

    <div>Severity Code Description Project File Line Suppression State</div> <div>Error CS0234 The type or namespace name 'WebRefSCX' does not exist in the namespace 'restClient_0' (are you missing an assembly reference?) restClient_0 C:\Users\Administrator\Desktop\VP-0-REST-Client-master\restClient_0\Form1.cs 25 Active</div>

    Thursday, March 19, 2020 10:05 PM
  • User-1852975005 posted

    Here is the code below.

    It contains a section that does HTTP

    and a section that does SOAP

    using Newtonsoft.Json;
    using RestSharp;
    using RestSharp.Authenticators;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Net.Http;
    using System.Text;
    using System.Threading.Tasks;
    using System.Web.Helpers;
    using System.Web.Script.Serialization;
    using System.Windows.Forms;


    namespace restClient_0
    {
        public partial class Form1 : Form
        {
            static object[] obj;
            restClient_0.WebRefSCX.SCXService MySoap;


            public Form1()
            {
                InitializeComponent();
                MySoap = new restClient_0.WebRefSCX.SCXService();
                StartSoap();
            }


            
            private void cmdGO_Click(object sender, EventArgs e)
            {


                var Client = new RestClient("https://xx.xx.xx.27:8443/rest/something/workService");


                Client.RemoteCertificateValidationCallback = (sender1, certificate, chain, sslPolicyErrors) => true;


                var request = new RestRequest();


                request.Method = Method.POST;


                request.AddHeader("authorization", "Basic xxxxxxxxxxxxxxxxxxx==");


                string POSTString = "{\r\n      \"action\": \"read\",\r\n      \"header\": {\r\n\t\t\"requestor\": \"WorkOrderCreateService\",\r\n\t\t\"dateTime\": \"DD/MM/YYYY HH:MM:SS\",\r\n\t\t\"messagePriority\": \"1\",\r\n\t\t\"correlationId\": \"\"\r\n\t},\r\n      \"payload\": {\r\n\t     \"workOrder\": {\r\n           \t\"workOrder\": \"02006523\"\r\n          \r\n\t\t}\r\n      }\r\n}";


                request.AddJsonBody(POSTString);


                IRestResponse response = Client.Execute(request);


                string strJSON = string.Empty;


                debugOutput(strJSON);


                txtResponse.Text = POSTString;


                txtResponce2.Text = response.Content;


                var result = JsonConvert.DeserializeObject(response.Content);


                string resultString = result.ToString();


                txtBox1.Text = resultString;
                //*************************


                RootObject Root = Newtonsoft.Json.JsonConvert.DeserializeObject<RootObject>(response.Content);


                //*************************


                string workOderString = Root.payload.workOrder.workDTO.workOrderDesc.ToString();


                txtBox2.Text = workOderString;


                //*************************


                bool successBool = Root.success;


                //bool successBool = Root.payload.workOrder.workDTO.calculatedMatFlag; //For Example of false


                txtSuccess.Text = successBool.ToString();


            }


            private void debugOutput(string strDebugText)
            {
                try
                {
                    System.Diagnostics.Debug.Write(strDebugText + Environment.NewLine);
                    txtResponse.Text = txtResponse.Text + strDebugText + Environment.NewLine;
                    txtResponse.SelectionStart = txtResponse.TextLength;
                    txtResponse.ScrollToCaret();
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Write(ex.Message, ToString() + Environment.NewLine);
                }
            }


            public void StartSoap()
            {
                GetValue.Enabled = false;
                SetValue.Enabled = false;
                if (ServerName.Text.Length > 0)
                {
                    // override default connection to server
                    MySoap.Url = "http://localhost/webservices/scx";
                }
                bool limit;
                obj = new object[0];
                object[][] retobj;
                PointList.Items.Clear();
                GetValue.Enabled = false;
                SetValue.Enabled = false;
                try
                {
                    // define SQL query, results are in retobj
                    retobj = MySoap.ExecuteQuery("Select FullName from CDBPoint", obj, out limit);
                    for (int i = 0; i < retobj.Length; i++)
                        PointList.Items.Add(retobj[i][0].ToString());
                }
                catch (Exception exc)
                {
                    ServerName.Text = exc.Message.ToString();
                }


            }


            private void PointList_SelectedIndexChanged(object sender, EventArgs e)
            {
                if (PointList.SelectedIndex == -1)
                {
                    GetValue.Enabled = false;
                    SetValue.Enabled = false;
                }
                else
                {
                    GetValue.Enabled = true;
                    SetValue.Enabled = true;
                }


            }


            private void btnSOAP_Click(object sender, EventArgs e)
            {
                Cursor.Current = Cursors.WaitCursor;
                StartSoap();
                Cursor.Current = Cursors.Default;
            }


            private void GetValue_Click(object sender, EventArgs e)
            {
                obj = new object[0];
                object[][] retobj;
                bool limit;
                retobj = MySoap.ExecuteQuery("Select CurrentValueFormatted, FullName from CDBPoint where FullName='" + PointList.SelectedItem + "'", obj, out limit);
                PntValue.Text = retobj[0][0].ToString();
            }


            private void SetValue_Click(object sender, EventArgs e)
            {
                obj = new object[1];
                object retobj;
                try
                {
                    obj.SetValue(float.Parse(PntValue.Text), 0);
                    retobj = MySoap.ExecuteMethod(PointList.SelectedItem.ToString(), "CurrentValue", obj);
                    ErrMessage.Text = "No Error";
                }
                catch (Exception exc)
                {
                    ErrMessage.Text = exc.Message;
                }
            }
        }
    }

    Friday, March 20, 2020 4:26 AM
  • User-1852975005 posted

    What package I'm I looking for?

    Friday, March 20, 2020 5:15 AM
  • User-1330468790 posted

    Hi, NewToDotyNet,

     

    Since your problem is caused when the client application calls a web service, could you please check if the below diagnosis from Microsoft support is suitable for your case?

    https://support.microsoft.com/en-us/help/823196/prb-you-receive-a-system-io-filenotfoundexception-error-when-the-clien

     

    If your condition fulfills one of the two causes, then you could follow the steps of the Resolution.

    • The worker process does not have permissions to read to the process Temp directory, and the worker process does not have permissions to write to the process Temp directory.

      Note The XmlSerializer class generates and compiles code on the fly to perform serialization and deserialization. XmlSerializer uses Code Document Object Model (CodeDom) to perform the compilation. CodeDom compilation uses temporary files on a disk. If the worker process does not have the read permissions on the Temp directory and the write permissions on the Temp directory, then all calls to the Web service fail. Therefore, the worker process requires the read permissions on the Temp directory and the write permissions on the Temp directory.

      -or-
    • There are compilation errors in the code that XmlSerializer generated.

     

    Hope this can help you.

    Best regards,

    Sean

    Friday, March 20, 2020 5:55 AM
  • User-1852975005 posted

    Hi, I started from scratch again. This time bringing code in from the opposite way around, program b into program a (and it seems to be working).

    Two errors

    Client.RemoteCertificateValidationCallback

    RestClient does not contain definition RemoteCertificateValidationCallback

    -----------------------------------------------------------------------------------

    request.AddJsonBody

    RestRequest does not contain definition AddJsonBody

    -----------------------------------------------------------------------------------

    I had to update the version of RestClient to suit the framework. So I am guessing definition names have changed?

    Thanks,

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 26, 2020 10:22 PM