reference Scripting compiling c# csc - c#

I need to compile via csc.exe this code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Scripting;
namespace ConsoleApplication13
{
class Program
{
static void Main(string[] args)
{
Scripting.FileSystemObject fso = new Scripting.FileSystemObject();
Scripting.Folder folder = fso.GetFolder(#"E:\backup_SQL_Planet\");
Int64 dirSize = (Int64)folder.Size;
string abc = Convert.ToString(dirSize);
Console.WriteLine(abc);
}
}
}
when i execute csc.exe there was a problem with reference of (using Scripting;)
How do I reference using Scripting?

Related

Program.cs file wont accept name of form that I've created

I've been creating an application for university coursework, using Visual Studio Forms, and I was trying to launch the form I've made to check it's connecting to the database behind it, but it won't accept the name of the form as legitimate. I have no idea why, as it is appearing in the Solution Explorer.
This is the code for the program.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FoxhillCustomer
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmViewEditStaff());
}
}
}
This is the code for the frmViewEditStaff.cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace FoxhillViewEditStaff
{
public partial class frmViewEditStaff : Form
{
SqlDataAdapter daViewEditStaff;
DataSet dsFoxhillDentistryFinal = new DataSet();
SqlCommandBuilder cmdBViewEditStaff;
DataRow drViewEditStaff;
String connStr, sqlViewEditStaff;
int selectedTab = 0;
bool staffSelected = false;
int staffNoSelected = 0;
public frmViewEditStaff()
{
InitializeComponent();
}
private void frmViewEditStaff_Load(object sender, EventArgs e)
{
connStr = #"Data Source = .\sqlexpress; Initial Catalog = InTheDogHouse; Integrated Security = true";
sqlViewEditStaff = #"select * from Staff";
daViewEditStaff = new SqlDataAdapter(sqlViewEditStaff, connStr);
cmdBViewEditStaff = new SqlCommandBuilder(daViewEditStaff);
daViewEditStaff.FillSchema(dsFoxhillDentistryFinal, SchemaType.Source, "ViewEditStaff");
daViewEditStaff.Fill(dsFoxhillDentistryFinal, "ViewEditStaff");
dgvStaff.DataSource = dsFoxhillDentistryFinal.Tables["Staff"];
dgvStaff.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
tabStaff.SelectedIndex = 1;
tabStaff.SelectedIndex = 0;
}
}
}
Your form is in a namespace of FoxhillViewEditStaff. Your Program class is in a namespace of FoxhillCustomer, and you don't have a using directive for the FoxhillViewEditStaff namespace.
I'd strongly advise you to:
Use a single namespace for all the classes in your project
Rename all your forms to follow normal .NET naming conventions, to make the code clearer
You could just add a using directive, but it would be more sensible to just put the classes into the same namespace, IMO.

how to run wamp server in c#

How do I do this? Can this be done through code in C# ? I use this code to do this but it doesn't work .
using System;
using System.Diagnostics;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Process.Start(#"C:\wamp64\wampmanager.exe");
}
}
}

WCF with Duplex Communication

Whenever I am using Window Forms It works Fine But it always give error with console applicion.
Error- The socket connection was aborted. This could be caused by an
error processing your message or a receive timeout being exceeded by
the remote host, or an underlying network resource issue. Local socket
timeout was '00:01:00'.
Here is My Code
Contract
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace ClassLibrary1
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IReportService" in both code and config file together.
[ServiceContract(CallbackContract=typeof(IReportServiceCallbak))]
public interface IReportService
{
[OperationContract(IsOneWay=true)]
void ProcessReport();
}
public interface IReportServiceCallbak
{
[OperationContract(IsOneWay=true)]
void Progress(int percentage);
}
}
Service
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Threading;
namespace ClassLibrary1
{
public class ReportService : IReportService
{
public void ProcessReport()
{
for (int i = 0; i < 100; i++)
{
Thread.Sleep(50);
OperationContext.Current.GetCallbackChannel<IReportServiceCallbak>().Progress(i);
}
}
}
}
Client
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Threading.Tasks;
using System.Threading;
namespace DuplexClientsss
{
class Program
{
static void Main(string[] args)
{
new Tests();
} }
class Tests : ReportService.IReportServiceCallback
{
ReportService.ReportServiceClient obj;
public Tests()
{
obj = new ReportService.ReportServiceClient(new InstanceContext(this));
obj.ProcessReport();
}
public void Progress(int percentage)
{
Console.WriteLine(percentage);
}
}
}
new Task
(
()=>
{
obj.ProcessReport();
}
).Start();

SafeArrayTypeMismatchException using VirtualBox from c#

I'm using the VirtualBox type library from C# as follows:
using System;
using System.Collections.Generic;
using System.Text;
using VirtualBox;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
IVirtualBox vbox = new VirtualBoxClass();
IHost h = vbox.Host;
Array a = h.USBDevices;
}
}
}
The line Array a = h.USBDevices; causes a SafeArrayTypeMismatchException. Has anyone else had the same problem?
Thanks!
var a = (IUSBDevice[])h.USBDevices

How to write an app-launching application with arguments in C#?

How to if I want to write an application that launches Firefox with arguments ?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace Launcher
{
public static class Program
{
public static void Main(string[] args)
{
Process.Start("C:/Program Files/Mozilla Firefox/firefox.exe");//this is ok
Process.Start("C:/Program Files/Mozilla Firefox/firefox.exe -P MyProfile -no-remote");// this doesn't work
}
}
}
You will need to specify the process.StartInfo.Arguments
See this question: Calling an application from ASP.NET MVC
You will need to use the process.StartInfo.Arguments, as shown here:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace Launcher
{
public static class Program
{
public static void Main(string[] args)
{
Process firefox = new Process();
firefox.StartInfo.FileName = #"C:\Program Files\Mozilla Firefox\firefox.exe";
firefox.StartInfo.Arguments = "-P MyProfile -no-remote";
firefox.Start();
}
}
}

Categories

Resources