GLControl does not exist in the namespace 'OpenTK' - monodevelop

I use OpenTK and MonoDevelop.
I use GLcontext
GLcontrol glControl1 = new GLControl();
I catch error:
'GLControl' does not exist in the namespace 'OpenTK'
I added OpenTK.dll, OpenTK.GLControl.dll, OpenTK.dll.config to my project.
Any Ideas.

Make sure you are using the correct libraries for your architecture. So for x86 make sure you have the x86 libraries. For x64 make sure you have the x64 libraries. Make sure you set the architecture for your startup project to the architecture to match the libraries using the configuration manager. On a 64bit machine it is usually set up by default as combile for 'Any CPU'. Change this to the correct platform.
This is the way I do it:
Create a new test windforms application. I want to do a 64bit application so I use the configuration manager to set my startup appliction to x64. Using NuGet install the opentk.glcontrol. It will automatically resolve OpenTK as a dependency and install it.
Here is some code adding the control and setting the background colour to skyblue:
using OpenTK;
using OpenTK.Graphics.OpenGL4;
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
private OpenTK.GLControl _glControl;
public Form1()
{
InitializeComponent();
_glControl = new OpenTK.GLControl();
_glControl.Dock = DockStyle.Fill;
this.Controls.Add(_glControl);
_glControl.Load += control_Load;
_glControl.Paint += control_Paint;
}
private void control_Paint(object sender, PaintEventArgs e)
{
_glControl.SwapBuffers();
}
private void control_Load(object sender, EventArgs e)
{
GL.ClearColor(Color.SkyBlue);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
}
}
}

Related

Example on how to wire up durable function dependency injection

Having successfully created and run a simple Azure Durable Function in Visual Studio 2017, I want to introduce logging.
The Visual Studio project template generates the static HttpStart class with a
Run method containing an optional parameter of type Microsoft.Extensions.Logging.ILogger.
I have no idea how to hook up dependency injection into a durable function project. Can anyone point me to an example on how to achieve this?
It looks to me like I will need some class, inside which I will need to use the Microsoft.Extensions.Logging.LoggingFactory.CreateLogger() method.
I imagine that this logic will need to be within a container class that is hooked into the run time pipeline using HostBuilder in some way (similar to using WebHostBuilder in static main method).
Thank you
#Thomas pointed me to examples I used to extract code that allows dependency injection to work when writing a durable function project:
using System.IO;
using System.Reflection;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog;
using NLog.Extensions.Logging;
using tmetadastoreFnApp;
using Willezone.Azure.WebJobs.Extensions.DependencyInjection;
using ILogger = Microsoft.Extensions.Logging.ILogger;
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
[assembly: WebJobsStartup(typeof(Startup))]
namespace tmetadastoreFnApp
{
internal class Startup : IWebJobsStartup
{
public void Configure(IWebJobsBuilder builder) =>
builder.AddDependencyInjection(ConfigureServices);
private void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<ILoggerFactory, LoggerFactory>();
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));
services.AddLogging((builder) => builder.SetMinimumLevel(LogLevel.Trace));
var serviceProvider = services.BuildServiceProvider();
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
loggerFactory.AddNLog(new NLogProviderOptions { CaptureMessageTemplates = true, CaptureMessageProperties = true });
var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
LogManager.LoadConfiguration(Directory.GetParent(dir) + "\\nlog.config");
}
}
}

Why I am getting a http request exception in Xamarin Forms

I am trying to execute this simple code but it fails and i get System.Net.Http.HttpRequestException: An error occurred while sending the request.
The code simply declares an HttpCLient and then I use the GetStringMethod. the same code used to work. I don't know why it doesn't now.
I searched google and stackoverflow and couldn't get the answer.
Here is my .cs file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using FetchActor.Models;
using Newtonsoft.Json;
using System.Collections.ObjectModel;
using System.Collections;
namespace FetchActor
{
public partial class MainPage : ContentPage
{
HttpClient connection = new HttpClient();
MovieService movieService = new MovieService();
public MainPage()
{
InitializeComponent();
}
private async void searchBarByActor_SearchButtonPressed(object sender, EventArgs e)
{
var _connection = await connection.GetStringAsync("https://api.themoviedb.org/3/search/keyword?api_key=ab3da1af35c55cc8b3780fbc9a2bf259&query=Charlize%20Theron&page=1");
}
}
}
the code never goes past GetStringAsync and i get the error.
any ideas on what could this be please ?
It seems the emulator wasn't get data from the connection. I turned the Wifi on and off and restarted the computer and the project. it still didn't work. it was showing connected but no internet.
the solution was turning off mobile data in the emulator so that it could be connected only with wifi.

How to only use IOC container from MVVMCross

I'm working on a existing Windows Phone project and want to use the IOC container from MVVMCross, but not the other extra features (yet).
I installed MVVMCross.Core 4.x and try to use 'ConstructAndRegisterSingleton' from the App() constructor of the Windows app, but it throws an Null ref exception.
Tried to find any bootstrapper, setup or initialization for MVVMCross but can't find any in the new 4.x core.
Anyone any idea?
Found it.... and it seems to work.
Just get MVVMCross.Core from Nuget and create a setup like:
internal static class Setup
{
public static void InitializeIoc()
{
CreateIocProvider();
// Register all services
Mvx.ConstructAndRegisterSingleton<ILoudnessLimitsRegulator, LoudnessLimitsRegulator>();
}
private static void CreateIocProvider()
{
// Ioc options
var options = new MvxIocOptions();
// initialize the IoC registry, then add it to itself
var iocProvider = MvxSimpleIoCContainer.Initialize(options);
Mvx.RegisterSingleton(iocProvider);
}
}

The type or namespace name 'MicroKernel' does not exist in the namespace 'Castle' (are you missing an assembly reference?)

I'm new to castle windsor and wanted to learn it.
I downloaded Windsor 2.5.3 for .net4 from here http://www.castleproject.org/castle/download.html
I built my first console app using vs2010 and try to play around.
The following are my code(very simple)
using Castle.Windsor;
using Castle.MicroKernel.Registration;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
WindsorContainer wc = new WindsorContainer();
wc.Register(Component.For<I>().ImplementedBy<C>());
var v = wc.Resolve<I>();
var result = v.M();
}
}
public class C : I
{
public string P1 { get; set; }
public int M()
{
return 100;
}
}
public interface I
{
int M();
}
}
But it didn't get compiled, error msg says:
The type or namespace name 'MicroKernel' does not exist in the namespace 'Castle' (are you missing an assembly reference?)
The type or namespace name 'Windsor' does not exist in the namespace 'Castle' (are you missing an assembly reference?)
I actually referenced castle.core and castle.windsor dlls and intellisense was working fine until compile....
I also noticed that when I double click the castle.windsor in reference, it's not showing the namespace hierarchy in object browser window.
I even commented out all my code, it still can't compile, says the same error msg.
Can you please advise what can I do to make it run. really appreciate it!!
The problem is likely the target framework of your project.
Open project properties, and look for the target framework dropdown. If it says .Net Framework 4.0 Client Profile, change it to .Net Framework 4.0.

Cannot add Controllers to Castle.Windsor in ASP.NET MVC

Given the following setup, I have three assemblies.
Web (ASP.NET MVC 3.0 RC1)
Models
Persistence (Fluent NHibernate, Castle.Windsor)
This is my ControllerInstaller.
using System;
using System.Web.Mvc;
using Castle;
using Castle.Windsor;
using Castle.MicroKernel;
using Castle.MicroKernel.SubSystems;
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
namespace Persistence.Installers
{
public class ControllerInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(
AllTypes
.FromAssembly(System.Reflection.Assembly.GetExecutingAssembly())
.BasedOn<IController>()
.Configure(c => c.Named(
c.Implementation.Name.ToLowerInvariant()).LifeStyle.Transient));
}
}
}
This is my ControllerFactory...
using System;
using System.Web;
using System.Web.Mvc;
namespace Persistence.Containers
{
/// <summary>
/// Utilize Castle.Windsor to provide Dependency Injection for the Controller Factory
/// </summary>
public class WindsorControllerFactory : DefaultControllerFactory
{
private readonly Castle.Windsor.IWindsorContainer container;
public WindsorControllerFactory()
{
container = WindsorContainerFactory.Current();
}
protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
{
return (IController)container.Resolve(controllerType);
}
}
}
This is my Application_Start in the global.asax file..
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
// Register the Windsor Container
ControllerBuilder.Current
.SetControllerFactory(typeof(Persistence.Containers.WindsorControllerFactory));
}
I am getting the error
No component for supporting the service Project.Web.Controllers.HomeController was found
at the GetControllerInstance.
So , I'm not really sure what I am doing wrong, and why I cannot get the Controllers registered.
Your Castle Windsor setup code all belongs in your Web project. It is nothing to do with Persistence.
This is causing the problem because your ControllerInstaller is trying to register the controllers in the Persistence assembly rather than the Web assembly with the following code:
System.Reflection.Assembly.GetExecutingAssembly().
So move the IoC code to the Web project and it will find your controllers.