I have been trying to create a custom control on Xamarin.Forms.
My solution builds just fine on UWP but with android I always get the same error :
Impossible to evaluate the expression "[System.Version]::Parse('')". String is either too long or too short.
How Can I solve this ???
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using App2;
using App2.UWP;
using Xamarin.Forms.Platform.UWP;
using Windows.UI.Xaml.Controls;
[assembly: ExportRenderer(typeof(NavigationPannel), typeof(NavigationPannelRenderer))]
namespace App2.UWP
{
class NavigationPannelRenderer : ViewRenderer<NavigationPannel, NavigationView>
{
protected override void OnElementChanged(ElementChangedEventArgs<NavigationPannel> args)
{
base.OnElementChanged(args);
if (Control == null)
{
NavigationView nav_view = new NavigationView();
nav_view.MenuItems.Add(new NavigationViewItem
{
Content = "My content",
Icon = new SymbolIcon(Symbol.Folder),
Tag = "content"
});
SetNativeControl(nav_view);
}
}
}
}
EDIT :
I made another solution and tried to redo everything step by step, my android project compiled just fine at first, but when I Added my UWP custom renderer, and after compiling it on Windows, it started showing the same error
Okay so I made it step by step again copy/pasting line by line for a third time and this time no error occurs.
I really don't know what happened here so if anyone has any idea i would still gladly accept it.
Related
I am trying to show a webpage in a form using C#. I am using CefSharp to show the webpage (as I would like to test & learn how it works). But since I have worked only on inbuilt webbrowser, I have no idea how to get started with CefSharp(Finding it difficult to get any tutorials). I tried to write this code which executes but the form shows nothing in it. Where am I going wrong ?
Here is my Code :
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 chrometest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Cef.Initialize(new CefSettings());
var test = new CefSharp.WinForms.ChromiumWebBrowser("http://www.google.com")
{
Dock = DockStyle.Fill,
};
this.Controls.Add(test);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
Edit :
I tried to run the example from https://github.com/cefsharp/CefSharp/tree/cefsharp/41/CefSharp.WinForms.Example
When I try to build the solution, it shows a dialog box saying "Restoring Nuget Package cef.redist.x64 3.2454.1317" with a progresss bar which takes hell lot of time to complete but never completes and after sometime it hangs.
Please help what should I do to get the example running.
The CefSharp project has a few different examples as part of the main project.
Basic Example using Nuget
https://github.com/cefsharp/CefSharp.MinimalExample
More Advanced Examples
https://github.com/cefsharp/CefSharp/tree/cefsharp/41/CefSharp.WinForms.Example
When you installed the project using Nuget it should have opened a Readme.txt file, it contains a lot of useful information.
https://github.com/cefsharp/CefSharp/blob/cefsharp/41/NuGet/Readme.txt
In the context of WinForms there's a few tutorials
http://www.codeguru.com/columns/dotnet/if-you-like-it-put-an-html5-ui-on-it.html
http://thechriskent.com/2014/08/18/embedded-chromium-in-winforms/
For those reading this looking for WPF, there's
http://www.codeproject.com/Articles/881315/Display-HTML-in-WPF-and-CefSharp-Tutorial-Part
http://www.codeproject.com/Articles/887148/Display-HTML-in-WPF-and-CefSharp-Tutorial-Part
More Links
https://github.com/cefsharp/CefSharp.Tutorial
http://thechriskent.com/category/net/cefsharp/
I'm trying to use the Process class but it gives me this compiler error every time I do
The name 'Process' does not exist in the current context
I've already added using System.Diagnostics; at the top of my code but I still get this error. Autocomplete wont even recognize the class.
Hear is the code. I've only included the Main method because the rest of the code has nothing to do with the error.
using System;
using System.Reflection;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
public class MainClass
{
static void Main()
{
AIRuntime adam = new AIRuntime("Adam", false);
adam.AIUpdate();
Process.Start(adam.directory); //adam.directory is just a string
}
}
My IDE is Xamarin Studio if it matters.
After web searching and attempts, I found the problem.
To fix this, I manually add a reference to System in my project options instead of just typing using System;. I also need to keep using System.Diagnostics; at the top. It's all in the picture below
Thanks guys for trying to help
I'm working with some Audio files in my app (mp3, wav, ..etc)
I was using the Audio Class from the Microsoft.DirectX.AudioVideoPlayback dll
so first I had to download the dll, after doing so, I went to Add Reference
then I browsed to the dll location, and added it
I also installed the DirectX 9.0 Web Setup
Now, i don't get any problem with just saying: Audio aud;
but if I do something like this:
Audio aud = new Audio(path);
or
Video vid = new Video(path);
if I press Ctrl+F5 the app will crash immediately, If i try to debug, I just can't see the debugging cursor, and if i keep pressing F10 nothing ever happens ..
I put it in a try/catch block, it didn't threw an exception ..
so what's goin on ?
how can i fix this ?
I even tried to make a whole new app, here's the whole code, there's nothing really in it:
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 Microsoft.DirectX.DirectSound;
using Microsoft.DirectX.AudioVideoPlayback;
using Microsoft.DirectX;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Audio aud = new Audio("C:\\Users\\vexe\\Desktop\\Songs\\Kimosabe.mp3");
}
}
}
Any help would be appreciated ..
Thanks in advance ..
add this code to your project:
using Microsoft.DirectX.DirectSound
using Microsoft.DirectX
I have a c# problem. I have created a project called 'classproject' and I have added several forms to project successfully and successfully ran the program, but there is this other windows form that I just added and when I double-clicked on the form, it took me to the code view and brought out this:
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;
namespace WindowsFormsApplication1
{
public partial class demo : Form
{
public demo()
{
InitializeComponent();
}
private void demo_Load(object sender, EventArgs e)
{
}
}
}
Now, my challenge is that the name of the project is meant to show by default after the namespace as in "namespace classproject" instead of "namespace WindowsFormsApplication1". Please can anyone help me out, what am I meant to do because have tried everything possible. Even if I change the name myself its still going to flag error... someone please help me as soon as possible.
I'm not sure exactly what your issue is. If you change the namespace manually in the code to classproject it should be fine. What error are you talking about? You would also need to change the designer code file as well (probably called demo.Designer.cs).
Just a side note as well. Standard naming convention for C# is to use Pascal-case (as in ClassProject).
You must change namespace in ALL files that was generated by Visual Studio. You can do it manually, or just set cursor on "WindowsFormsApplication1", press F2 and enter new name.
Optionaly you can also change namespace in project properties on Application tab - then all new files added to project will also have namespace that you set there.
I've search the forum, but I coundn't find anything that quite satisfied me.
In Microsoft Visual Studio 2010, when I try to add a WPF User Control I get this error:
"Value cannot be null. Parameter name: objectType"
Then when I want to select the hosted content, I get this error :
"An error occured trying to add references for type 'PolyPuttZe.GameCanvas', or finding the type. Make sure the project references are correct."
I followed this tutorial : http://www.switchonthecode.com/tutorials/wpf-tutorial-using-wpf-in-winforms
Thanks!
EDIT:
This is the code I wrote :
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 System.Windows.Forms.Integration;
namespace PolyPuttZe
{
public partial class Game : Form
{
public Game()
{
InitializeComponent();
}
}
}
Here's a more useful answer for the next person that has this issue - you need to create your WPF user control and build the solution first. Then open/create the form and add an Element Host and set it to your control. This is likely what the accepted answer means as starting over would work as well if you create the WPF control first.