Sfml UserControl error when adding it to form - c#

It seems when I add my user control to my winform it throws this error:
Failed to create component error. 'SfmlControl'. The error message follows: 'System.DllNotFoundException: Unable to load DLL 'csfml-graphics-2': the specified module could not be found. (Exception from HRESULT: 0x8007007E)
I get it with this code
using System;
using System.Collections.Generic;
using System.ComponentModel;
//using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MapEditorLib.Classes;
using SFML.System;
using SFML.Window;
using SFML.Graphics;
namespace TileEditor
{
public partial class SfmlControl : UserControl
{
TileSet TileSet;
RenderTexture RenderTexture;
//Constructor
public SfmlControl()
{
InitializeComponent();
}
//Events
protected void OnLoad(object sender, EventArgs e)
{
RenderTexture = new RenderTexture((uint)Size.Width, (uint)Size.Height);
TileSet = new TileSet();
TileSet.Load("C:\\Users\\Shadowblitz16\\Desktop\\LinkBank1_S.png");
}
protected void OnPaint(object sender, PaintEventArgs e)
{
RenderTexture.Clear(Color.Black);
RenderTexture.Display();
}
}
}
I think the problem comes from me not including the dlls directly in the root of the project. However I don't want to do this, because it clutters the project and makes navigating harder.
I was wondering if there was a easy way to relocate them to my project directory under a 'Library' folder or if this was even related to the dlls.

Related

Can't Complete Code over File error how do i fix

I can't seem to figure out what is going on here.
I have posted below my code and a photo:
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 OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace test
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
ChromeOptions options = new ChromeOptions();
options.AddExtensions(new File("pathtoextentions.crx"));
IWebDriver driver = new ChromeDriver(options);
//Test Opening Website
driver.Navigate().GoToUrl("https://google.com");
}
}
}
I have also uploaded a photo here where it show my error is on new File: https://ibb.co/Lk72dsD
Error CS0712 Cannot create an instance of the static class 'File'
What am I doing wrong?
File is a static class, you can't create instances of it like new File().
Looking at ChormeOptions.AddExtensions, it accepts an array or an IEnumerable of string.
So, we could use an array in your case. To do so, replace this:
options.AddExtensions(new File("pathtoextentions.crx"));
with this:
options.AddExtensions(new[] { "pathtoextentions.crx" });

Windows Forms Application - axvlcplugin2 error in Release mode

I'm currently using axVLCPlugin2 in my Windows forms application.
I imported it from COM Components and axAXVLC and AXVLX are added to references. Everything works as expected in debug mode.
But it throws an exception in Release mode when I try to load the form that contains the plugin (Form3). It says:
system.Runtime.InteropServices.ExternalException: 'A generic error
occurred in GDI+.'
in Form3.Designer.cs at
((System.ComponentModel.ISupportInitialize)(this.axVLCPlugin21)).EndInit();
this.ResumeLayout(false);
Also an error message pops up saying :
An exception has been encountered. This may be caused by an extension.
I'm sure that the problem is with plugin as everything works fine when the plugin is removed from form.
Below is my code for Form3.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;
namespace WindowsFormsApp1
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
public string source;
private void Form3_Load(object sender, EventArgs e)
{
axVLCPlugin21.Size = this.Size;
axVLCPlugin21.playlist.add(source, null, null);
axVLCPlugin21.playlist.play();
}
private void Form3_ResizeEnd(object sender, EventArgs e)
{
axVLCPlugin21.Size = this.Size;
}
private void Form3_FormClosed(object sender, FormClosedEventArgs e)
{
axVLCPlugin21.playlist.stop();
}
}
}
I'm currently using vs community 2017, my target platform is .net 4.5 and vlc Version 2.2.6(Latest Stable).
Any ideas on how to fix this problem?
Sorry for longer description and thanks in advance.

Make sure that the class defined in this code file matches the 'inherits' attribute 3

I recently inherited another vendor's project and I am trying to turn it into a usable Visual Studio 2010 solution.
The error I'm currently running into is:
Make sure that the class defined in this code file matches the
'inherits' attribute, and that it extends the correct base class (e.g.
Page or UserControl).
I have found this question posed several other times, but none of the solutions seem to work in this case. Below is the code in question:
~/layouts/Header.ascx.cs
using System;
using Client._Classes.Global;
using Client._Classes.Helpers;
using Client._Classes.Utilities;
namespace Layouts.layouts_Header
{
public partial class layouts_Header : BaseControl
{
private void Page_Load(object sender, EventArgs e)
{
}
protected void lnkSignIn_OnClick(object sender, EventArgs e)
{
Session["CurrentPageURL"] = Sitecore.Context.RawUrl;
Response.Redirect("/en/Community/Register.aspx");
}
protected void btnSearchSubmit_OnClick(object sender, EventArgs e)
{
string redirectURL = "/en/Search%20Results.aspx?cx=005917832522243245879:kpcudcaotoo&cof=FORID:11&ie=UTF-8&q=" + txtSearchQueryStr.Text;
Response.Redirect(redirectURL);
}
}
}
~/layouts/Header.ascx
<%# Control Language="C#" AutoEventWireup="true" CodeFile="~/layouts/Header.ascx.cs" Inherits="Layouts.layouts_Header.layouts_Header" %>
BaseControl.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Globalization;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Web;
using Sitecore.SharedSource.Data.Comparers.ItemComparers;
using Sitecore.Data.Fields;
using Sitecore.SharedSource.Searcher;
using Sitecore.SharedSource.Searcher.Parameters;
using Sitecore.SharedSource.Searcher.Utilities;
using Sitecore.Collections;
using Client._Classes.Utilities;
using Client._Classes.Helpers;
using Client._Classes.Global;
namespace Client._Classes.Global
{
public class BaseControl : System.Web.UI.UserControl
{
...
}
}
It should be noted that several other .ascx controls inherit from BaseControl as well, and there does not appear to be any issues.
I think that the problem is that your namespace name ends with your class name:
namespace Layouts.layouts_Header
{
public partial class layouts_Header // * snip *
Try removing the layouts_Header part from your namespace and then change the value of the Inherits attribute to Layouts.layouts_Header
It appears that the solution provided to me contained a folder structure as such:
/temp/installation_history/681FBB6D58774C7D96B37D1353B7441E/layouts
which contained copies of Header.ascx and Header.ascx.cs. I discovered these files when I excluded the actual copies from Header.ascx and Header.ascx.cs from my project.
Once I removed the temp folder and all of its contents, the solution compiled. Thanks everyone for the advice.

'System.Web.UI.WebControls.Image' does not contain a definition for 'FromStream'

I'm trying to get image from web service and I'm getting an error.
'System.Web.UI.WebControls.Image' does not contain a definition for 'FromStream'
My Code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace SmartPoster
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// call web service here
SmartPosterV1 a = new SmartPosterV1();
MemoryStream mem = new MemoryStream(a.returnTestImage());
this.pictureBox1.Image = Image.FromStream(mem);
}
}
}
PictureBox is a WinForms control, and it's Image property is a System.Drawing.Image.
In ASP.Net, you need to have a System.Web.UI.WebControls.Image in your web form and assign the ImageUrl property the URL of the image to be displayed.

C# CefSharp Blank Page

I am trying to learn how to use CefSharp as a browser in c# (unless anyone can suggest any better alternatives).
Initially I set the configuration to Any CPU (and edited the .csproj and app.config) , but the browser didn't display any content, instead it just shows a white/grey screen.
I then tried changing the configuration to x64 (as my PC is x64), but after doing got the following errors:
The type or namespace name 'Winforms' does not exist in the
namespace 'CefSharp'
The type or namespace name 'ChromiumWebBrowser' could not be found
The "FindUnderPath" task was not given a value for the required parameter
"Path".
The OutputPath property is not set for project 'cef.csproj'. Please check
to make sure that you have specified a valid combination of Configuration
and Platform for this project. Configuration='Debug' Platform='x64'. This
error may also appear if some other project is trying to follow a project-
to-project reference to this project, this project has been unloaded or is
not included in the solution, and the referencing project does not build
using the same or an equivalent Configuration or Platform.
My code is:
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 CefSharp;
using CefSharp.WinForms;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
public ChromiumWebBrowser chrome;
public Form1()
{
InitializeComponent();
InitializeChromium();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public void InitializeChromium()
{
CefSettings settings = new CefSettings();
Cef.Initialize(settings);
string url = "https://www.google.co.uk/";
chrome = new ChromiumWebBrowser(url);
this.pContent.Controls.Add(chrome);
chrome.Dock = DockStyle.Fill;
}
private void pContent_Paint(object sender, PaintEventArgs e)
{
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Cef.Shutdown();
}
}
}
Any help or suggestions are greatly appreciated.

Categories