I am trying to do image manipulation in c# in windows 7 using VS 2012 express desktop. I made a console app with this code, and its giving errors about Bitmap cannot be found. Does anyone know whats wrong?
I already imported the system.drawing, but still cannot be found...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace ImageSplit
{
class Program
{
static void Main(string[] args)
{
System.Drawing.Rectangle cropRect = new Rectangle(0, 0, target.Width, target.Height);
Bitmap src = Image.FromFile(fileName) as Bitmap;
Bitmap target = new Bitmap(cropRect.Width, cropRect.Height);
using(Graphics g = Graphics.FromImage(target))
{
g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height), cropRect, GraphicsUnit.Pixel);
}
}
}
}
Make sure you include a reference to the System.Drawing assembly in the project. Referencing/importing the namespace is not enough for the linker to find the assembly in question. This is what the error message is referring to by "Are you missing an assembly reference?"
Right-click the project, select "Add Reference..." and choose the appropriate file. This will add a reference to the assembly in the /References virtual project folder.
Related
I'm trying to start my first project with Cppsharp using Visual Studio 2015, following the getting started guide.
The steps I followed were to:
Create new C# console project
Install Cppsharp using Nuget
Add references to Dlls into the project
Create C# source file based on the example in this old post
Whilst the example in the post is old, it still seems to be consistent with the getting started guide. The full program is listed below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CppSharp;
namespace CppSharpTest
{
class Program
{
class DllDemoGenerator : ILibrary
{
static void Main(string[] args)
{
ConsoleDriver.Run(new DllDemoGenerator());
}
void Setup(Driver driver)
{
var options = driver.Options;
options.GeneratorKind = LanguageGeneratorKind.CSharp;
options.LibraryName = "DllDemo";
options.Headers.Add("DllDemo.h");
options.Libraries.Add("DllDemo.lib");
}
public void SetupPasses(Driver driver) { }
public void Preprocess(Driver driver, CppSharp.AST.Library lib) { }
public void Postprocess(CppSharp.AST.Library lib) { }
}
}
}
However, I am already facing errors See image:
CS0012 C# The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=...'
I was not able to find a way to add this reference. One solution I found proposed to target a higher .NET version (4.7.2) and I tried this, but the error still remains.
Can anyone help to overcome this problem?
Posted the same question on the Github page and was recommended to upgrade from VS2015
Installing VS2019 removed this error
I am using Visual studio 2015 to build an app Universal by C++;
When I want to convert Textbox->Text to float type. I search google but don't have solve. I can't use TryParse or Convert:: or float.parse.
Here is the using of my Mainpage.cpp
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
and I can't use System::. When I write it show a syntax error
Try the code below.
String^ text = "3.14";
std::wstring textToConvert = std::wstring(text->Data());
float value = std::stof(textToConvert);
I am using selenium version 2.45 with internet explorer 11 and works well
but i have problem in assert function and tr and catch they aren't included!!
so how can i start maybe i did something wrong btw i start with console application and added reference (Selenium WebDriver, Selenium WebDriver Support Classes, WebDriver-backed Selenium, Selenium Remote Control.)
if there is something wrong kindly tell me how can i start from first
-my code open google and search for amazon then open amazon and search for something invalid i want make it return that there is no data find
so how can i search for text on page line "did not match"
thanks in advance.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Diagnostics;
using System.Collections;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;
class GoogleSuggest
{
static void Main(string[] args)
{
IWebDriver driver = new InternetExplorerDriver();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
driver.Navigate().GoToUrl("http://www.google.com/");
driver.FindElement(By.Id("lst-ib")).SendKeys("amazon");
driver.FindElement(By.Id("lst-ib")).SendKeys(Keys.Enter);
driver.FindElement(By.ClassName("r")).Click();
driver.FindElement(By.Id("twotabsearchtextbox")).SendKeys("akajerhfbds bvksajhgrcbskhb");
driver.FindElement(By.Id("twotabsearchtextbox")).SendKeys(Keys.Enter);
Thread.Sleep(6000);
driver.Quit();
}
}
I did a search on Amazon for "asdvasdv" - inspecting the elements, there is one with an id of "noResultsTitle" - if Amazon is consist with this you can use
FindElement(By.CssSelector("[id*='noResults']"))
My question is very similar to this one, only that the answer and work-around are not working for me. Also I am in Visual Studio 2012.
I have a VSPackage which is referencing another project, which is dependent on other dlls. Everytime time I run my package in debug I get an exception that the other dlls cannot be found. They are in the output directory, and they are signed.
I tried referencing them directly by the VSPackage project to no avail.
Thoughts?
This problem exists because Visual Studio is not looking for assemblies in a folder of your extension if your extension has no explicit dependence on these assemblies. For example, dependences set in a configuration file (IoC config) or in xaml code. I know three solutions to this problem:
You can deploy these assemblies in the GAC and Visual Studio will load them. This method is good if you use a third-party library that built for use in the GAC (for example, MS Enterprise Library). But VSIX Deployment Package does not allow installing assemblies in the GAC, you can use the MSI installer.
For VSPackages for Visual Studio 2010/2012 you can use ProvideBindingPath attribute. The path where your extension located will be added to the paths that Visual Studio uses to find dependent assemblies. If your extension doesn't include a VSPackage, you can add this attribute to any public class (see here).
[ProvideBindingPath]
public class MyVsPackage : Package
{ /* ... */ }
You can manually resolve assembly names. To do this, you need to subscribe to the AssemblyResolve event and you need to return required assemblies from a handler. This is the most flexible way, if you cannot use the previous methods, this is especially for you.
In my IntelliDebugger project, I wrote a class ManualAssemblyResolver for it:
using System;
using System.Reflection;
namespace IntelliEgg.Debugger.Utility
{
public class ManualAssemblyResolver : IDisposable
{
public ManualAssemblyResolver(Assembly assembly)
{
if (assembly == null)
throw new ArgumentNullException("assembly");
_assemblies = new[] {assembly};
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
}
public ManualAssemblyResolver(params Assembly[] assemblies)
{
if (assemblies == null)
throw new ArgumentNullException("assemblies");
if (assemblies.Length == 0)
throw new ArgumentException("Assemblies should be not empty.", "assemblies");
_assemblies = assemblies;
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
}
public void Dispose()
{
AppDomain.CurrentDomain.AssemblyResolve -= OnAssemblyResolve;
}
private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
{
foreach (Assembly assembly in _assemblies)
{
if (args.Name == assembly.FullName)
{
return assembly;
}
}
return null;
}
private readonly Assembly[] _assemblies;
}
}
This class must be created before the first call to the problem assembly (e.g., in Package::Initialize() method)
I am looking at this site : https://bitbucket.org/geckofx/geckofx-14.0
I don't know anything about GeckOFX, so downloading the the zip file I make references to Geckofx-core-14 and Geckofx-WinForms-14.
I use the this code...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Gecko;
using GeckoFX;
namespace GeckoFXTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//Gecko.Xpcom.Initialize("C:\\tools\\xulrunner");
GeckoWebBrowser myBrowser = new GeckoWebBrowser();
this.Controls.Add(myBrowser);
myBrowser.Dock = DockStyle.Fill;
myBrowser.Navigate("http://www.google.com");
}
}
}
But I think I am missing something, can someone tell me what I am missing? OR how to get started, I can't find docks for GeckOFX 14
Using C# WinForms 4.0 .Net
Thanks in Advance.
The line you have commented out is important:
//Gecko.Xpcom.Initialize("C:\\tools\\xulrunner");
You need to download xulrunner 14 or firefox 14 and tell geckofx where to find it, by calling Gecko.Xpcom.Initialze before creating the GeckoWebBrowser control.
Also you only need to call Xpcom.Initialize once per application so you prolly don't want to put it in your Form Constructor.
You can download xulrunner-sdk
https://bitbucket.org/geckofx/geckofx-33.0/downloads
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Gecko;
using Gecko.DOM;
using System.Net.Mail;
using System.Net.Mime;
using System.IO;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Gecko.Xpcom.Initialize(#"F:\bak\Desktop\frefox c sharp\xulrunner-33.1.1.en-US.win32.sdk\xulrunner-sdk\bin");
}
private void button4_Click(object sender, EventArgs e)
{
geckoWebBrowser1.Navigate("http://example.com");
}
}