Hari
Hari

Reputation: 13

What's wrong with my C# code

I'm writing a C# console application that use API of Visual Web Ripper. I wrote a program that worked when I gave specified the file path in the code it self and the code is

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VisualWebRipper;
using VisualWebRipper.Processor;

namespace VisualWebRipperAPI
{
    class Program
    {
        static void Main(string[] args)
        {
            WrProject project= WrProject.Load("C:\\Users\\User\\Desktop\\news.rip");

            project.DataConfiguration.DataSource.OutputFolder =@ "C:\\Users\\User\\Desktop\\output";
            project.DataConfiguration.DataSource.IsDefaultOutputFolder = false;
                 IAgent agent = WrAgent.RunProject(new WrProcessPars(project, false, false, false, project.DefaultCollector, project.LogLevel), true);

            string status = agent.Status;     
            int  processedPages = agent.ProcessedPages;     
            int  pageLoadErrors = agent.TimeoutPages;      
            int  missedRequiredElements = agent.MissedRequiredElements;
            bool isError = agent.IsError;
            Console.WriteLine(status +" "+ processedPages +" "+  pageLoadErrors +" "+  missedRequiredElements  +" "+ isError);
            Console.ReadLine();
        }
    } 
}

But now I'm trying to change my code to mention the input and output file paths in the object. I added two classes code.cs and program.cs

in code.cs I wrote

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VisualWebRipper;
using VisualWebRipper.Processor;

namespace webripperplugin
{
    public class code
    {

        public void method(string source,string output)
        {
            WrProject project = WrProject.Load(source);
            project.DataConfiguration.DataSource.OutputFolder = output;
            project.DataConfiguration.DataSource.IsDefaultOutputFolder = false;
            IAgent agent = WrAgent.RunProject(new WrProcessPars(project, false, false, false, project.DefaultCollector, project.LogLevel), true);

            string status = agent.Status;
            int processedPages = agent.ProcessedPages;
            int pageLoadErrors = agent.TimeoutPages;
            int missedRequiredElements = agent.MissedRequiredElements;
            bool isError = agent.IsError;
            Console.WriteLine(status + "\n" + processedPages + "\n" + pageLoadErrors + "\n" + missedRequiredElements + "\n" + isError);
            Console.ReadLine();
        }

    }
}

And in program.cs I wrote

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VisualWebRipper;
using VisualWebRipper.Processor;
using webripperplugin;

namespace webripperplugin
{
    class Program
    {
        static void Main()
        {
            code trail = new code();
            trail.method("C:\\Users\\User\\Desktop\\news.rip", @"C:\Users\User\Desktop\output");

        }
    }
}

But my program in not working as it supposed to be.It is showing two warnings

  1. There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "WebRipper", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
  2. There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "WebRipperBrowser", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project

When I ran it earlier I used to get desired output and now I'm getting no output

Upvotes: 0

Views: 212

Answers (1)

krystan honour
krystan honour

Reputation: 6793

Ok so the WebRipper binary targets x86 and you probably have Any CPU ticked or x64 ensure there is a config for x86 active and that error should go away. You can do that in the project file if you click properties on the file and change the architecture in the compile tab (platform)

Also try the following:

  1. Go to the Build > Configuration Manager menu item.
  2. Find your project in the list, Platform should say Any CPU.
  3. Select Any CPU then select New
  4. Now select x86.
  5. make sure Any CPU is selected.
  6. Hit OK

This needs to be done for both the Debug and Release settings.

Upvotes: 1

Related Questions