Could not load file or assembly 'ConsoleApplication1' - c#

I just open a new C# project , but when i want to compile it i give the title error . i search for this error but didn't find any result .
what am i going to do ?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("hello world!");
}
}
}

Try cleaning the project.
Make sure that the startup item isn't set
to a non-existant ConsoleApplication1.
Whatever the main form of
your project is, right click on it in Solution Explorer and select
"Set as Start Up...".
Make sure that the Program.cs (or Program.vb)
file is not attempting to load ConsoleApplication1.

Related

How can I add a static 'Main' method suitable for an entry point?

I am getting an error on my code that says "Error CS5001
Program does not contain a static 'Main' method suitable for an entry point"
I am coding in C# using Microsoft Visual Studio and .NET. This is my code.
using System.IO;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using System;
class projectsummer
{
[CommandMethod("OpenDrawing", CommandFlags.Session)]
public static void OpenDrawing()
{
string strFileName = "C:\\DRAFT.dwg";
DocumentCollection acDocMgr = Application.DocumentManager;
if (File.Exists(strFileName))
{
acDocMgr.Open(strFileName, false);
}
else
{
acDocMgr.MdiActiveDocument.Editor.WriteMessage("File " + strFileName +
" does not exist.");
}
}
}
I am not sure how to go about this error. Thank you!
Looking at this post and your previous question, let's try and break down what's going on.
You created a new Console application in Visual Studio. You did not tick "Do not use top level statements". This gave you a Program.cs file that was essentially empty (there was no "Main" method visible).
You erased the Hello World code given to you, and went to make a static method - the code from your previous question.
Damien_The_Unbeliever commented that based on the error, you put your method inside a "top level statement" file, and to put your method inside a class.
You wrap your method (which is still inside Program.cs) in a class, and now suddenly you get a Can't Find Entry Point error.
User Ryan Pattillo posted a great explanation of the original issue - where your method was "by itself" in the Program.cs file. You should follow their advice, but you should also ensure that this class is in its own file.
You should end up with this:
Program.cs
// this is the entire contents of the file
using ConsoleApp1;
ProjectSummer.OpenDrawing();
ProjectSummer.cs
using System.IO;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using System;
namespace ConsoleApp1
{
public class ProjectSummer
{
[CommandMethod("OpenDrawing", CommandFlags.Session)]
public static void OpenDrawing()
{
// ...
}
}
}
Change ConsoleApp1 to the name of your project.
The entry point of your application, which right now is the only file that has "top level statements", remains Program.cs, thus you fix the Can't Find Entry Point error.
Another adjustment you can make, which seeing you're new to C# might be useful, is to not use top level statements at all. Modify your Program.cs to this:
namespace ConsoleApp1
{
internal static class Program
{
// this is your program's entry point
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
ProjectSummer.OpenDrawing();
}
}
}
Change ConsoleApp1 to the name of your project.
You cannot use the AutoCAD .NET API out of process. To be able to use the AutoCAD .NET libraries, you have to build a "class library" project (DLL) and NETLOAD this DLL from a running AutoCAD process. See this topic about in-process vs out-of-process and you can start from this other one to see how to create an AutoCAD .NET project.

unable to locate element method LinkText in c# selenium and visual studio 2013

I exported some code from Selenium IDE into my C# page in Visual studio 2013 and it keeps giving me this error. I just copied the steps from the exported document into my c# page. The platform finds the LinkText on the actual page but it keeps giving me this error.
I changed it to find the element by id but, then I don't know how to select the menu item in webpage.
I will really appreciate your help with this.
Thank you
I get this error:
{"Unable to locate element: {\"method\":\"link text\",\"selector\":\"My Resume\"}"}**
This is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
namespace MyFirstAutoScript
{
class Program
{
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("https://yelitzascareerjourney.wordpress.com/");
driver.FindElement(By.LinkText("My Resume")).Click(); //my page brakes here
more commands go here...
}
}
}
You must have to mouseover first on menu item "About Me" before
clicking on sub menu item "My Resume". And you can use Actions commands from Selenium for same.
I don't have much idea about C# but your code would be something like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Interactions;
namespace MyFirstAutoScript
{
class Program
{
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("https://yelitzascareerjourney.wordpress.com/");
new Actions(driver).MoveToElement(driver.FindElement(By.LinkText("About Me"))).Click().Build().Perform();
driver.FindElement(By.LinkText("My Resume")).Click(); //my page brakes here
more commands go here...
}
}
}
I had used new Actions(driver).MoveToElement(driver.FindElement(By.LinkText("About Me"))).Click().Build().Perform(); to mouse over on menu item.

Sikuli Integrator C#

I want to use SikuliIntegrator in C#.
I run VS as administrator, install SikuliIntegrator throught NuGet manager and want to test him on simple task.
Heres my code
using SikuliModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SikuliTrainingNet
{
class Program
{
static void Main(string[] args)
{
string MyPicture = #"c:\111\Sik\MyPicture.png";
SikuliAction.Click(MyPicture);
}
}
}
after running code (and have prepared MyPicture on screen), all i get is exception "###FAILURE" any idea why?
I dont wanna use Sikuli4Net, becose its look like it work on web aps and I need just few simple clicks on desktop aplication.
I try sikuli in Java, and there it works with no problem. But I need to make my program in C#.
I Used This Code For Sikuli4Net in C#,It Was Working For Me First You need add the References please see this link for Reference
http://interviews.ga/angularjs/sikulic/
static void Main(string[] args)
{
APILauncher launch = new APILauncher(true);
Pattern image1 = new Pattern(#"C:\Users\Ramesh\Desktop\Images\userName.png");
Pattern image2 = new Pattern(#"C:\Users\Ramesh\Desktop\Images\password.png");
Pattern image3 = new Pattern(#"C:\Users\Ramesh\Desktop\Images\Login.png");
launch.Start();
IWebDriver driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Url = "http://gmail.com";
Screen scr = new Screen();
scr.Type(image1, "abc#gmail.com", KeyModifier.NONE);
scr.Type(image2, "12345", KeyModifier.NONE);
scr.Click(image3, true);
Console.ReadLine();
}
I used this code and it was working fine. First you should open the webpage on which you want to click and then give a path of the image(it should be a part of the webpage)
here is my code:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SikuliModule;
using OpenQA.Selenium;
namespace WordPressAutomation.DifferentTests
{
[TestClass]
public class Sikuli
{
[TestMethod]
public void TestMethod1()
{
driver.Initialize();
driver.instance.Navigate().GoToUrl("https://www.google.co.in");
SikuliAction.Click("E:/img.png");
}
}
}
To use SikuliInyegrator, you need to check the execution results in these files:
C:\SikuliExceptionLog.txt
C:\SikuliOutputLog.txt
Also you need to:
Have installed JRE7 or superior
Have environment variable PATH with the location of the bin folder
See installed in your “control panel > program and features> visual C++ 2010 Redistributable Package” at x86 and x64 bits according to your java JRE runtime platform. If not, then download and install the Redistributable Package form Microsoft site.

cannot create instance of supersocketserver AppServer

I am trying to get the SuperSocketServer app up an running. However, I cannot seem to create an instance of the server. Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperSocket.SocketBase;
using SuperSocket.SocketBase.Config;
using SuperSocket.SocketEngine;
using SuperSocket.SocketBase.Protocol;
namespace WinnieServer
{
class Program
{
AppServer W = new AppServer();
static void Main(string[] args)
{
Console.Write("Starting...");
while (true)
{
}
}
}
}
I tried the examples in the source code. However, they all give the same error:
Cannot create an instance of the abstract class or interface 'SuperSocket.SocketBase.AppServer'
Is this the correct way to create an instance of SSS?
take care,
lee
I had this same issue. The download on their home screen gives you the 1.4.4 version. If you look in object explorer it IS abstract. If you go to their downloads and grab the binaries zip, you'll get the 1.5 version that ISN'T abstract.

OpenFileDialog no show in different AppDomain

I have this simple code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using System.IO;
using Microsoft.Win32;
using System.Xml;
namespace ConsoleApplication1
{
class Program
{
public static void Main(string[] args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog();
}
}
}
which I compile when clicking a button with CSharpCodeProvider. I then load it into a new AppDomain and run the Main method, but the open file dialog is never shown. I know it is running as I have tested this.
Also trying to unload the domain results in an error.
If anymore information is needed just ask!
Most likely the AppDomain you created doesn't have the FileDialogPermission. This means of course that trying to use an OpenFileDialog will fail. See here for more information.
Assuming the namespace you're using reflects the type of application: you cannot use OpenFileDialog just like that!
Have you tried adding [STAThread] before the main function?
[STAThread]
public static void Main(string[] args)
Several components of the operating system, such as dialogs, use COM components, which to be communicated with, need to have this attribute present in the entry point of the program.

Categories