The type or namespace name 'EventHandler' does not exist in the namespace 'Windows.UI.Xaml' - event-handling

I'm trying to build a Metro app using the Windows 8 SDK, but when I try to actually compile it using Visual Stuido I get this
The type or namespace name 'EventHandler' does not exist in the namespace 'Windows.UI.Xaml'
Keep in mind, I'm a total beginner, is this easy to fix?

The type EventHandler is not contained in that namespace. One of your using statements must reference "System" since that is where this type lives
OR
You can use the fully qualified name of the object, such as "System.EventHandler".
If you are doing something like "Windows.UI.Xaml.EventHandler" you would get that error OR if you only declared ONE using statement at the top of your file such as "using Window.UI.Xaml".
Without knowing more about or seeing your code, it's difficult to say with absolute certainty. If this doesn't resolve your problem, include your code.

Related

Typing fully qualified type names in powershell?

I want to reduce typing System and other root namespaces, for example
[string] $ComputerName = [Environment]::MachineName
vs.
[System.String] $ComputerName = [System.Environment]::MachineName
Another example:
[Net.Dns]::GetHostEntry("192.168.1.1")
vs.
[System.Net.Dns]::GetHostEntry("192.168.1.1")
Are there any reasons and specific situation when typing System and similar parent namespaces is required?
I often wonder why is there System namespace after all since everything is inside that namespace so what the deal with that namespace? it's a nonsense; what is the term System supposed to mean anyway? it's not related to operating system here. but to everything in NET framework.
I assume that there may be exceptions when calling static methods, but I don't know C# so unable to answer this myself.
In somewhat jumbled order:
it's a nonsense; what is the term System supposed to mean anyway?
The "System" in question is the .NET runtime and framework. The original idea, as far as I understand, was that code that doesn't ship with .NET would fall under different namespaces - but multiple Microsoft-authored components built on top of .NET has since made use of System parent namespace - including all the APIs that make up PowerShell itself.
I often wonder why is there [a] System namespace after all since everything is inside that namespace so what the deal with that namespace?
Not "everything" is inside the System namespace, but as mentioned above, everything that ships with the runtime or base class libary is - which is exactly why PowerShell automatically resolve type literals even if you omit System. from a qualified type name - PowerShell is trying to help you reduce typing already
Are there any reasons and specific situation when typing System and similar parent namespaces is required?
Yes - when the parent namespace is not System.
The first example that comes to mind is the .NET wrapper classes for the Win32 registry API on Windows:
$HKLM = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, [Microsoft.Win32.RegistryView]::Default)
Now, for the actual question:
I want to reduce typing System and other root namespaces
You can't add custom namespace prefixes (like System) to PowerShell's name resolution method, but you can declare automatic resolution of type names in specific namespaces in PowerShell 5 and up, with the using namespace directive.
Without using namespace:
[System.Net.Dns]::GetHostEntry("192.168.1.1")
With using namespace:
using namespace System.Net
[Dns]::GetHostEntry("192.168.1.1")
When used in a script, any using directives must precede anything else in the file, including the param block.
using namespace directives will work in an interactive session as well, granted that you issue it as a separate statement:
PS> using namespace System.Net
PS> [Dns] # still works!
By the way, powershell has a lot of "type accelerators" like [datetime], can you make your own, like [dt]: Boolean and bool difference?

EF broken after update database. A namespace cannot contain members such as fields or methods

I have researched this topic and pulled up a couple of hits that I thought might have helped me. So far I am still pulling out my hair over here because everything was fine until I added a field to a table in Azure and then tried to update my model.
Here's a short sitrep of what the problems have been and what I have done to solve them.
Problem 1
Compiling transformation: Metadata file 'C:\Program Files\VS2013\Common7\Tools..\IDE\Microsoft.Data.Entity.Design.dll' could not be found
Compiling transformation: Metadata file 'C:\Program Files\VS2013\Common7\Tools..\IDE\EntityFramework.dll' could not be found
I solved the problem by changing my global environment variable in advanced system properties to the correct location of these files, which in my case was : F:\Program Files (x86)\Common7\IDE
This is probably due to the fact that I just installed VS 2013 ultimate on my F drive; however, I have been developing on it successfully now for a week and never had a problem until now.
After this I run into problem 2:
Problem 2
A namespace cannot directly contain members such as fields or methods C:\Users\Adrian.Campos\Documents\Visual Studio 2013\Projects\ConsoleApplication2\ConsoleApplication2\Model1.cs 1 1 ConsoleApplication2
As you can see the problem is arising from my Model1.cs class. My .edmx file is named model1 (fyi)
I found some links that weren't of help to me since my error is coming from a different source than that of the links.
VS2012: My Entity Framework model doesn´t get included to my project output using InstallShield
A namespace cannot directly contain members such as fields or methods.
A namespace cannot directly contain members... + Type or namespace definition, or end-of-file expected errors
That last link seemed the most promising; however, it did not fix my problem. What I do not understand is how in the world did everything just blow up after I updated my model?
Has anyone else experienced this and fixed it?

Error in objective C

I am trying to run unit test whereby I am getting an warning:
'FileName' may not respond to '-failWithException:'
I wanted to know why this warning occurs and how to fix that?
Either the FileName interface does not declare the failWithException: method, or you have not imported the header file in which the interface is declared.
Whatever sort of object FileName is, the compiler can't find a method named '-failWithException' in that class. The solution is to go implement that method on that class, or to make sure the compiler can find the header file where it already is implemented.
By the way, it's a warning instead of an error because, unlike for instance Java, Objective-C allows you to manipulate classes at runtime. So while you PROBABLY have a problem there, you don't DEFINITELY have a problem, so the IDE gives you a yellow warning rather than a red error. But in your case, this is almost certainly something you need to fix.

What happened to the Rx Switch() operator?

I am working my way through the Hands-On-Labs for reactive extensions (Rx HOL .NET.pdf) which I downloaded from the data developer center (here) a few days ago.
I added these references to my project, using NuGet:
System.Reactive 1.0.10621.0
System.Reactive.Windows.Forms 1.0.10621.0
I'm almost done with the labs, but I've hit a snag trying to implement the .Switch() example, Visual Studio can't locate the extension method:
'System.IObservable'
does not contain a definition for
'Switch' and no extension method
'Switch' accepting a first argument of
type
'System.IObservable'
could be found (are you missing a
using directive or an assembly
reference?)
Now I know this Hands On Labs document is out of date, because certain things have been renamed (FromEvent became FromEventPattern) and certain things were removed (RemoveTimeStamp) and this document does not reflect that. For the life of me I cannot guess what they renamed Switch to be, or figure out what assembly they might have moved it to, or find a comprehensive list of release notes that indicate it was removed.
Anyone know where I can find Switch and what it's current name is?
The Switch extension method doesn't extend IObservable<T> - it extends IObservable<IObservable<T>>. The full signature is:
IObservable<TSource> Switch<TSource>(this IObservable<IObservable<TSource>> sources)
Try typing Observable.Empty<IObservable<object>>(). and see if Switch appears then.
If not, check your using namespace declarations.

How can I set boilerplate information for the files generated by catalyst.pl?

When I use catalyst.pl to auto-generate my application, the AUTHOR section of the POD includes only my name like this.
Kiffin Gish,,,
What are the missing fields and how can I use them? Is it possible to use another boilerplate for the PODs?
It's using the GECOS field from your line in the passwd file (courtesy of getpwuid). You can change the author name that shows up by setting the AUTHOR environment variable, although this doesn't seem documented. As for overriding the entire thing: not so much, unless you want to write your own catalyst.pl that uses a custom subclass of Catalyst::Helper, or submit the patch to -Runtime to let everyone do that.:)