missing assembly reference viewport c# wp8 xna - c#

I was recreating this sample about using motion API for creating an Augmented Reality app for WP8.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202984(v=vs.105).aspx/css#BKMK_CreatingaSilverlightbasedAugmentedRealityApplication
I followed everything right. Used the correct using statements too. But the Viewport is not detected as a class in microsoft.xna.framework.graphics or microsoft.xna.framework.
I tried to look everywhere on the internet regarding this, but in vain. I even installed the xna framework to get those dll files for microsoft.xna.framework.graphics.dll and others. But when I add the dlls manually as references I get the following error.
"A reference to a higher version or an incompatible assembly cannot be added to the project."
Without viewport, the app is useless.
How do I add the xna framework class library to VS2012 so that my app looks at that dll file ?

There is no Viewport class in WP8. However there was the same problem with the GART toolkit, and it was solved by implementing a Viewport class. You can go to the project page and browse the source code to see how it is implemented:
http://gart.codeplex.com/SourceControl/latest#GeoARToolkit/NonXnaUtils/Viewport.cs

Related

Migrate Xamarin Forms Effect to .NET MAUI

For a Xamarin Forms application, I have been using a solution to track touch using code from an example out of Microsoft's Xamarin Forms Sample Project, specifically the Touch Tracking Effect sample.
I took that sample and simplified it down to just directly starting up with the BoxViewDraggingPage.xaml from App.xaml.cs and removing all other XAML files. That compiled and ran fine.
I then created a .NET Maui App with the same BoxViewDraggingPage (and the same TouchActionEventArgs.cs, TouchActionEventHandler.cs, TouchActionType.cs, and TouchEffect.cs) as was in the Xamarin Forms version.
I added the same TouchEffect.cs files that were in the sample for the specific platforms (iOS also has a TouchRecognizer.cs file)
When running it at that point I got the following:
So then I tried following the instructions for Migrating Xamarin.Forms Effects. The explanation for how Xamarin.Forms effects were set up matched perfectly, but it was unclear to me from that page what class the section titled "Effects in .NET MAUI" was replacing since it had a different class name than the previous code snippets earlier in the article. It seemed like it is replacing the FocusEvent class in the shared platform code and then specifies the platform specific code within #if platform sections (#if WINDOWS, #if __ ANDROID __, etc.) and so I am guessing that means the TouchEffect.cs files are no longer needed in the platform specific folders.
I didn't have a chance to find out if that was the case or if it works, because when I try to compile, I get:
I don't find any missing Nuget packages or assemblies when I tried searching. If I click the dot after Platform, I get the following choices, with instructions to use the navigation bar to switch contexts:
But I am already targeting net6.0-windows10.0.19041.0:
so I'm not sure why it says Not Available for that.
So, I am stuck trying to get this to work.
I am looking either for a solution to get the sample code working as it is in the Xamarin.Forms project, but for .NET MAUI (whether that be set up how the sample originally had it or how it is described in the Migrating Xamarin.Forms Effects link) - it could be that I am missing something simple in how to get that Microsoft.Maui.Controls.Compatibility.Platform.UWP piece to compile.
Or, the other possibility is that same link says that .NET MAUI Handlers can also handle this type of scenario. So if someone can show all the pieces that would need to be modified in order to do the same solution but using .NET MAUI Handlers, I am open to that. But it seems that the easiest path, though, should be to get the Effects working in .NET MAUI since everything is already written that way. I am just leaving both options open in looking for a solution.
EDIT:
OK, I figured out why the UWP portion had red squiggles under it. I figured out what "using the navigation bar to switch contexts" in the above screenshot meant. It meant I needed to select the context in the dropdown pictured below:
However, this just moves the squiggles to PlatformEffect and I cannot figure out what to do with the context or anything else to resolve that:
OK, I found out that PlatformEffect now inherits from Microsoft.Maui.Controls.PlatformEffect instead of the separate Platform inheritances shown in the Migrating Xamarin.Forms Effects example. That example is out of date and I didn't realize that and so it was confusing me.

Creating Wp8 Unity Plugin in Unity 5.0

I have a windows phone 8.0 plugin created for an app. This app worked perfectly fine in Unity 4.5. I recently updated my Unity to 5.0. I also saw all the needed alterations.
Initially, we needed to create two plugin dlls. One actual and one empty simply like an interface for the editor. This went pretty well in unity 4.5
Now i open the same app in Unity 5.0 by upgrading it. and i am unable to build it for wp8 anymore. I set the inspector platforms correctly to WP8 player for my plugin dll.
But, i keep getting errors like ::
1. Plugins are colliding.
2. There are errors in the script (which are actually not)
3. Cannot load classes from module.
4.System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
etc.
Can anybody help me? I have tried several things already but none seems to work.
I tried :
1. Reimporting everything
2. Rebuilding the dlls.
3. Removing the empty interfaced dll for editor
4. Changing the folder structure for plugins. (Default being
Assets/Plugins/WP8)
I am stuck here since two days now.
Well, it's too late to reply. But anybody else stuck in same problem may get help.
One should know that WP8 Plugins are based on real and fake dlls in order to work in Unity Editor.
In Unity 5, you can specify platform to dll, irrespective of folder structures. However if you put dll in Assets->Plugins->WP8. Unity will mark it as WP8 dll.
Solution is,
1- Put Fake dll in Assets->Plugins->AnyFolder->plugin.dll, where any AnyFolder is other than WP8 folder. Mark it as Editor instead of Any Platform (from inspector [Select platform for plugins]).
2- Put Original dll in Assets->Plugins->WP8->plugin.dll, mark it as WP8Player
3- Keeping original dll selected, in Platfrom Settings [Inspector] modify settings like, CPU -> Any CPU, check mark on Don't Process, Select placeholder.
Placeholder drop down would show the path of fake dll, just set it.
Now you are all done :)
You must set the editor DLLs to "Editor" instead of "Any Platform" and the WP8 plugins to "WP8Player" in the plugin settings.

Grid is not supported in a Windows Presentation Foundation (WPF) project

I am learning how to create a Class Library (Windows Store apps) and used a UserControl template to add a user control to it.
Then I added a Grid tag to accompanying XAML. However, the tag is underlined with blue squiggles and when I hover over the tag there is
Grid is not supported in a Windows Presentation Foundation (WPF) project
tooltip shows up.
The library seems to build without errors. I've added the library to an application and use the control in its code. The application is also builds just fine. However, when I run the application I get XamlParseException exception.
I am using Visual Studio 2012 RTM. Both the library and the application reference only two standard assemblies (.NET for Windows Store apps and Windows).
What I might done wrong and how should I fix the library?
In my case I switched from Debug to Release, and then back, and the error was gone.
Go to "Build > Configuration Manager..." and Make a new platform for x86 for all your projects.
It doesn't have to be the active one, you can leave that as Any CPU.
Hope it works as for mine...
I've recently had the same error and found the following in the output window:
10>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFX.targets(268,9): error MC6000: Project file must include the .NET Framework assembly 'WindowsBase, PresentationCore, PresentationFramework' in the reference list.
The solution for me was to add the missing references to my project.
For me it helped to set the "Target framework" in application-properties to .NET 4.0
This appears to be a bit of a "catch-all" for a number of XAML resource errors. I've found two causes so far:
Declaring a Resource outside of the appropriate context- e.g. directly in a UserControl tags, not UserControl.Resources.
Forgetting to include the correct namespace for the "unsupported" class. Example in a basic ResourceDictionary, with no sys namespace defined:
<ResourceDictionary>
<sys:string>I'm not supported</sys:string>
</ResourceDictionary>
I was able to solve my similar issue of..
UserControl is not supported in a Windows Presentation Foundation (WPF) project
.. by removing the PresentationFramework reference and re-adding it via nuget.
[Reposting comment as answer]
I was able to complete the steps with no issues, and it appears you were able to as well. Perhaps there was some other inadvertent modification/setting that was made?
This is xaml getting itself confused. I have the error on one project and not on another. Have a look at the top of the xaml before the grid error and see if there are any references to other controls. Try making a modification that will cause and error and rebuilding one of those controls. Then put it back the way it was to get a succesful build and see if this makes the grid error go away. (it did for me)
Much Like Felix D.s answer, I found from the .csproj file a reference was removed.
Obviously replace the 3 with your needed framework, or use the project properties to set the version ( i think that adds this reference )
Evil Dog Pie was step 1 for me, as some other issues came up. There is always a heap of information in the output log
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
This problem is due to the low version of .NET that you have chosen in your project.
To solve the problem, select the Project from the up menu and then select your Project Properties and from the part of Target Framework select higher version of .NET Framework!
I hope your problem is solved.
Yours sincerely

Developing a Cross Platform XNA Library

I'm trying to develop a cross platform application.
Currently I have set up following solutions, with their platform specified template:
GameBase
Windows
Xbox
WindowsPhone
The Windows, Xbox and WindowsPhone uses the GameBase as reference, but I want to separate different code for each platform used in the GameBase library as the example below:
#if WINDOWS
graphics.PreferredBackBufferWidth = 640;
graphics.PreferredBackBufferHeight = 480;
graphics.ApplyChanges();
#elif WINDOWS_PHONE
TargetElapsedTime = TimeSpan.FromTicks(333333);
InactiveSleepTime = TimeSpan.FromSeconds(1);
#endif
It does not work, and I can see that in the Configuration Manager, that GameBase's platform is Any CPU, so I wonder if it has anything to due with the GameBase being a Class Library?
If so how do I fix it, and if possible I would like to keep the #if tags.
Directory setup | Windows Solution Game.cs | Solution Explorer
You have to create separate Visual Studio projects for the different platforms. You can reuse code across multiple projects by adding the source using Add As Link. Within a shared source file that is linked to multiple project you can use #if etc. to separate platform specific code.
How "It does not work" is not clear from your question but in general you cannot build an assembly (e.g. class library) for Windows and then use it on XBox and Windows Phone.
Sharing projects between different project types is a tricky thing to do - just because of the way Visual Studio project types are used and because the different project types actually need to reference different versions of the dot net framework.
There are a few things that can assist:
the Portable Class Library tools - http://msdn.microsoft.com/en-us/library/gg597391.aspx
the Project Linker plugin - http://msdn.microsoft.com/en-us/library/ff921108(v=PandP.20).aspx
manual cut and paste (including add link like above)
Hope that helps a bit. Personally I'm currently mainly using manual cut and paste and hoping that the next version of the Portable Class Library helps (it is due for Win8 Metro stuff)
Not sure if this is your only problem but you mispelled WINDOWS_PHONE:
WINDOWS_HPONE
should be:
WINDOWS_PHONE
UPDATE:
The way that I would do it is I would create a class library solution calling it something like GameBaseLibrary. Then create a project there called GameBase and add all code in there that you would like to share across all the platforms. (I.E. Physics, data access, etc...)
Then in that same solution add XboxBaseLibrary, WindowsBaseLibrary, WindowsPhoneBaseLibrary and add code which is specific to each platform, add a reference in each of those projects to the GameBase project to use code from there in each of the three other projects.
Then create 3 different solutions types - Xbox, Window, Windows Phone and add the compiled dlls from GameBaseLibrary as a reference in each of them to be able to use the code. As you're working on each version of code (xbox, windows, windows phone) pay attention to code that you're typing to ensure that it's not something which can live within the GameBase class because you don't want to keep rewriting the same code.
This way, the bulk of the code is sitting in GameBaseLibrary and the platform specific code is sitting within each of the 3 other projects.
I hope this is clear.

Are there any known compatibility issues with Microsoft Media Platform: Player Framework (formerly SMF) and Silverlight 5?

I'm trying to get the default template (adaptive streaming) for the MMPPF framework to work.
Currently I'm not getting any error, but the player does not play any videos. I've tried adding other sources besides the default, I can see them added in the playlist, but they won't play either.
Using Fiddler I can see that the player does not even attempt to retrieve the manifest (or anything else).
The online example here works fine, I've even tried using that manifest as a source, but it still won't play when I run it in Visual studio.
So my question, could this have anything to do with having Silverlight 5 toolkit installed? I would assume that the MMPPF/SMF template is supposed to work out of the box (which is also stated on the Codeplex site). Or is there something else I'm missing?
You may need to add some references to your project. MMPPF is using MEF to resolve plugins at run-time, and it can fail silently if it doesn't find a suitable plugin.
For Smooth Streaming, you need both Microsoft.SilverlightMediaFramework.Plugins.SmoothStreaming and Microsoft.Web.Media.SmoothStreaming for it to work for instance.
Update:
I've encountered another reference issue when migrating a project. I had to remove and re-add System.ComponentModel.Composition, then add System.ComponentModel.Composition.Initialization.
I tried to uninstall the Smooth Streaming Client that the MMPPF client installed and installed the newest from here, added a reference to the new dll (Microsoft.Web.Media.SmoothStreaming.dll) and everything worked.

Categories