Why do I get 'CultureAndRegionInfoBuilder not found' error? - c#

Okay, this is a strange one.
I'm trying to create a custom culture in Xamarin using:
using System.Globalization;
...
var x = new CultureAndRegionInfoBuilder();
But I get the nasty red Resharper error with no options.
The type or namespace name 'CultureAndRegionInfoBuilder' does not exist in the namespace 'System.Globalization'
What's going on, am I missing something? Can't find any help on google...

Related

Problem with reference to another project

I have 1 solution with 2 projects (TcpClient and TcpServer) in TcpProtocol namespace.
Folders:
TestProject/source/TcpProtocol.Client/TcpClient.cs
TestProject/source/TcpProtocol.Server/TcpServer.cs
I have added this to the TcpClient project:
using static TcpProtocol.Server; // for use static values in TcpProtocol.Client.
But when I try to build a project, I get the following error message:
"The type or namespace 'Server' does not exist in the namespace 'TcpProtocol' (are you missing an assembl reference?)"
It's strange, because reference exist, but under name of reference I see yellow triangle.
If instead of using static write like this in code all work fine:
TcpProtocol.Server.port = 8008;
Why doesn't it work with static? How do I fix it?
Never used that before but I would understand the docs that you have to target a type/class.
Your code sample seems to target a namespace...

How can i fix Application' is an ambiguous reference between 'System.Windows.Application' and 'System.Windows.Forms.Application'

i tried using "System.Application' "System.Windows.Application"
Code:
pastebin . com LK5F8HpA
i could not say it here
The way to resolve ambiguities like these is by understanding what you are using and why you are using it.
Then use the proper using/importing declaration and or use fully qualified name so that your program can compile and you do not have ambiguity problems.
When you ask a question, Please provide more information about what Framework you are using and what version and what kind of applications you are building...
Form? WPF? Core or full version? etc
In DotNet Namespace: System.Windows.Forms.Application, Assembly System.Windows.Forms.dll
While in core: Namespace:System.Windows, Assembly:PresentationFramework.dll
Use fully qualified name to solve this problem quickly.
According to Msdn link you can use namespace alias and '::' operator to fix your issue.
Quick fix
using forwinforms = System.Drawing;
using forwpf = System.Windows;
public class Converters
{
public static forwpf::Point Convert(forwinforms::Point point) => new forwpf::Point(point.X, point.Y);
}
If there is need for both assemblies in one class, simply preface the specific types with the entire namespace.
So:
System.Windows.WhatEverIsNeededHere foo = new System.Windows.WhatEverIsNeededHere();
And:
System.Windows.Forms bar = new System.Windows.Forms();

"Name 'Process' does not exist in current context" error in console app

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

Why can Visual Studio detect which "using" is needed, but then say the type or class which provoked the addition of the reference does not exist?

On trying to build, all of a sudden (a couple of days since I worked on this project) I get:
"The type or namespace name 'IO' does not exist in the class or namespace 'OpenNETCF' (are you missing an assembly reference?)"
But when I comment out that line (using OpenNETCF.IO.Ports;), I get:
? OpenNETCF.IO.Ports.Handshake (multiple choices...)?
When I click that, the choices are two:
OpenNETCF.IO.Ports.Handshake
- and:
OpenNETCF.IO.Serial.Handshake
As the code in this unit deals with printing, I select "Ports" (rejecting "Serial" because of its yin/yanginess to "Parallel"). So it then adds back the using I had which it complained about (using OpenNETCF.IO.Ports)...and then it's back to the original err msg.
Yet I do have several OpenNETCF items in my References, namely:
OpenNETCF
OpenNETCF.Data
OpenNETCF.Drawing
OpenNETCF.Net
OpenNETCF.Phone
OpenNETCF.VisualBasic // I don't know why, this is a C# project
OpenNETCF.Web.Services2
OpenNETCF.Windows.Forms
OpenNETCF.WindowsCE.Forms
OpenNETCF.Xml
What could possibly cause this chicken-and-egg tail-chasing exercise in frustration?
Odder yet, I get, "The type or namespace name 'Windows' does not exist in the class or namespace 'OpenNETCF' (are you missing an assembly reference?)" pointing to this using in another .cs file:
using OpenNETCF.Windows.Forms;
...and yet that using is grayed out as being unused at any rate, but when I comment it out, I get a lot of other errors purportedly because it's gone, such as on this line:
IntPtr hwnd = OpenNETCF.Win32.Win32Window.GetCapture();
The type or namespace name 'Win32Window' does not exist in the class or namespace 'OpenNETCF.Win32' (are you missing an assembly reference?)
UPDATE
In another episode of "Well Flip My Bits!" I just now compiled, got those err msgs about not being able to reconcile this line of code with what is installed and configured, etc., scrolled up to see that the "using" it was supposedly missing was there, compiled again, and now it compiles fine. What the blue blazes?!?!?!?
This sounds like a problem you see when you are building a project for a "Client Profile" .net version while referencing assemblies that are not supported in client profile.
Try changing your project's build settings to use a .net framework version that is not "Client Profile".
One can use the namespace using inside class also, so consider moving it there, if there are classes that use both than use the full name as in OpenNETCF.IO.Ports.Handshake handshake = new OpenNETCF.IO.Ports.Handshake()
And for the class using namespace:
using System;
namespace MyNamespace
{
using OpenNETCF.IO.Ports;
//...
}

Dynamically adding usercontrol to placeholder

I'm having a brain freeze moment today. I must've done this many times but just can't work it out:
All i'm doing is running the following, but it's not saying releasestable is right.
Error 55 The type or namespace name 'releasestable' could not be found (are you missing a using directive or an assembly reference?) C:\Users\tomb\Documents\Visual Studio 2010\Projects\Findnzbs\Findnzbs\latestreleases.aspx.cs 16 11 Findnzbs
Heres the code:
releasestable webUserControl = (releasestable)Page.LoadControl("~/controls/releasestable.ascx");
webUserControl.listWhere = "myWhere";
phReleases.Controls.Add(webUserControl);
because you need to add it on the top of your code
like
using System.Collections;
using System.Data;
using Findnzbs.Controls;
is it
releasestable webUserControl (releasestable)Page.LoadControl("~/controls/releasestable.ascx");
webUserControl.listWhere = "myWhere";
or
releasestable webUserControl= (releasestable)Page.LoadControl("~/controls/releasestable.ascx");
webUserControl.listWhere = "myWhere";
Ok then the solution is add your namespace of the control.
example
if your application name is demoproject, then add
using demoproject.Controls;
where Controls is the folder were you have control code.
in your case it is Controls. so just copy paste the above line

Categories

Resources