How to add Storage reference? - c#-4.0

This should be pretty straightforward, but can't work this out for myself I'm afraid!
The following line of code triggers the error:
using Microsoft.Xna.Framework.Storage;
Error: The type or namespace name 'Storage' does not exist in the
namespace 'Microsoft.Xna.Framework' (are you missing an assembly
reference?)
But as far as I can tell, I have added the reference: (Solution explorer -> right click References -> Add reference -> .NET tab -> scroll down to Microsoft.Xna.Framework.Storage -> select it -> click OK).
Microsoft.Xna.Framework.Storage shows up when I expand "references" in the solution explorer.
What am I missing?
EDIT
Okay on second look this might be to do with how I'm adding the references. When I search in the object browser Microsoft.Xna.Framework.Storage doesn't show up (but when I search, for example, for audio, Microsoft.Xna.Framework.Audio does show up). Is there anyway to check that when I click "OK" on the add reference pop-up that it is actually working?

I see two likely possibilities.
You have a mismatch of XNA 4.0 and XNA 3.1 (or previous) references in your project. If the Storage reference you added is from 3.1, you'll get this message. You can try removing it, and then looking specifically for the 4.0 version during add.
The device you are building for may not support the Storage mechanism. In particular, Windows Phone apparently uses a different storage mechanism (System.IO.IsolatedStorage http://msdn.microsoft.com/en-us/library/ff604992.aspx).
Hope one of these helps.

This question was asked a long time ago, but if anyone else is still looking for an answer, here is how i fixed it.
If you installed the Microsoft.Xna.Framework references by using the installer from Microsoft, then it installs in C:\Windows\Microsoft.NET\assembly. I found all of the Xna libraries in GAC_32 and Microsoft.Xna.Framework.Storage in GAC_MSIL.
You can also use the GAC to find libraries that aren't in Visual Studio's reference list. For .NET Framework versions before 4.0, the libraries are in C:\Windows\assembly, and the libraries for versions after 4.0 are in C:\Windows\Microsoft.NET\assembly.

It's actually been removed from Monogame by Microsoft.
Running: Windows 10, with integrated graphics card (Intel G45/G43), Visual Studio 19, Monogame 3.7.1
Project Structure: Solution > Game.Shared, Game.Android, Game.OpenGL (followed this guide on creating a Cross-Platform project, method number 3).
I changed the Target Framework in my OpenGL project from .NET 4.5 to .NET 4.7.x (the newest version), and I was able to build and deploy the app to an Android device. Do this by clicking the project and selecting Properties.
I simply commented out the line. App will successfully deploy to an Android device this way. The game will then deploy, but I can't get any content to load.
Have yet to see if I can deploy to an iOS device, I will update this post when I figure out if I can.
No nuGet's installed.

Related

Universal Windows Plateform And Live SDK

I have a problem. I recently installed VS 2015 and Windows 10 on my computer.
Having Universal Apps are amazing and I plan to convert some of my programs on UWP.
But I have a problem. In one of my programs, I allow the user to save its datas on its OneDrive. And if OneDrive is unavailable, the datas are stored on local devices.
And when OneDrive is available, the newly stored datas are pushed to OneDrive. Synchronisation in fact.
So it is the problem. In the UWP dll named Universal.Live I have installed Live SDK 6 with Nuget. During the package installation, there is some work done to see if the Live SDK is compatible with UWP.
Great ! It's compatible and successfully installed.
But when I wrote
using Microsoft.Live;
The name is not recognized. And if I use the class LiveAuthClient which is in the namespace, it isn't recognized too...
This is a real problem :( Any ideas ?
I had the same issue adding the Live SDK to my app. For some reason the Package.JSON isn't correctly resolving and downloading the package (or recognizing it).
Either way, just add the DLL to your references the old fashioned way. Personally, I'd just add it to a console app (not using the new Project.json package), get it from NUGET, and grab the DLL from the Packages.
After you have the DLL:
Right click on References
Add Reference -> Browse...
Find the DLL and add it. ("...\\packages[LiveSdk]...")
It works!
Download it from here, Compile it, and grab the desktop SDK:
https://github.com/liveservices/LiveSDK-for-Windows
You can also download the msi, install it, figure out where the DLL is installed to and grab it from there:
https://www.microsoft.com/en-us/download/details.aspx?id=42552
According to this GitHub issue, LiveSDK isn't supposed to be used for Universal Windows Platform apps: https://github.com/liveservices/LiveSDK-for-Windows/issues/58
Instead we should use these SDKs that cover the same functionality:
Mail/Calendar/Contacts: https://dev.outlook.com/
Files/OneDrive: https://dev.onedrive.com/

Could not find SDK Bing.Maps.Xaml, Version=1.113.0601.1

I am working with windows 8.1 store app.In my app using the bing map sdk. I have added the bing map sdk extention.But I got the error "Could not find SDK Bing.Maps.Xaml, Version=1.113.0601.1".Please give a suggestion.
The version of Bing Maps you are referencing is for Windows 8 only. There is a new version that is for Windows 8.1. The new version has some additional features and a lot of bug fixes. You can find the Windows 8.1 Bing Maps control here: http://visualstudiogallery.msdn.microsoft.com/224eb93a-ebc4-46ba-9be7-90ee777ad9e1
Check if you have installed the latest version of the sdk since the one you've added the reference to is not for Window 8.1.
Also, one other possible solution consists in editing and removing the reference to the Bing Maps elements directly in your csproj file.
So to do as said, here are the steps:
Edit the csproj (or vbproj) file directly as xml content (right-click, unload the project and right-click Edit the csproj)
Remove the element that references the Bing Maps control inside the section
Save the document and reload the project then add the reference using the usual way
If, for an unknown reason it won't work, it might be useful to uninstall and reinstall the Bing Maps extension (SDK) and do the same process as before by removing and adding back the reference to the extension.

Project is targeting frameworks not installed or are included as part of future updates to Visual Studio

I am attempting to convert the Microsoft.Health C# class library that is installed as part of the HealthVault SDK, using instructions provided here. After following these instructions, I get the following error when attempting to load the project into Visual Studio 2013.
"The project is targeting frameworks hat are either not installed or
are included as part of future updates to Visual Studio. See
http://go.microsoft.com/fwlink/?LinkId=287985"
Visiting the link takes me to .NET SDKs and Downloads. Once there, I have no clue on what needs to be done.
I do realize that one will have to leverage the Portable Class Library Contrib project to fill in some missing bits, especially code related to System.Security. This, I will deal with later.
Any one run into a similar problem?
Maybe so late but for those who have the same problem.
I had the same error in a project which was working perfect before updating VS2013 and finally after 3 hours looking for the source of the error I found that the error is about TargetFrameworkProfile.
In my case I sloved it like so:
Right click in the unloaded project in your solution and click Edit.
Find the TargetFrameworkProfile tag and set it as below:
<TargetFrameworkProfile>Profile78</TargetFrameworkProfile>
At a guess, this is because you need to specify the TargetFrameworkVersion and TargetFrameworkProfile properties in the project file. Compare the .csproj you are trying to create to a newly created PCL project file, and make sure that everything that's not specific to your project matches.
I ran into the same issue and got it resolved by installing the latest Visual Studio Update

How to create crashlytics binding for Xamarin.iOS?

I've downloaded Crashlytics app that integrates Crashlytics.framework into XCode project, and it works great for XCode. But as far as I know, to build Xamarin.iOS binding I need static library, and I can't find it neither in framework nor in Crashlytics.app contents. There is only "run" executable and header. I don't know how to use it under Xamarin.iOS. Btw, AndrewReed on Xamarin forum managed to build dll somehow, so it's possible.
So, how to create crashlytics binding for Xamarin?
AndrewReed answered this question on Xamarin forum:
As with quite a few sdk's, sometimes they bundle a folder instead of the static lib,which essentially is the static library. There will be a sizeable file that maybe doesnt have an extension(this is your .a file) so you can rename that to be .a and then include that in a xamarin bindings project. Run the sharpie marker on the header file in the folder which will generate your necessary files. Watch out for one gotcha, delegate is a reserved word in c#, so you may need to go around and change this by adding an # symbol(to the name) to allow you to use the reserved word.
So what I actually did was, created a project in xcode and ran the crashlytics programme, this then added the crashlytics framework to the project. In finder locate that and you will have a structure like so: - run - /Versions --/A ---Crashlytics ---/Headers ----Crashlytics.h
So the /A folder is essentially your static lib, use this and create your binding from that, or in this particular case, just download it from the mono bindings || my repo.
If you're looking for an officially supported crash reporting plugin, Crittercism just released one (Full disclosure: I'm one of the co-founders). You can download the bindings from the Xamarin store here: http://components.xamarin.com/view/crittercism
The latest version of Xamarin seems to have it build in.
Here are the steps that I followed
1.) In the Xamarin Studio , go to the main app, and add the Crashlytics API key in the Build -> Crash reporting section. Build and run that app. The evidence suggests that is enough to get data sent to Crashlytics. I saw that it knew about older versions of the app I had built and ran weeks ago with the API key already in.
2.) Go to Xcode and create a new project with the same name as the Xamarin project, com.{company}.{appname}. (You probably need to have that profile downloaded.) I did it in Swift by the way with no issues.
3.) Go to crashlytics.com com and go to settings -> Apps (or https://www.crashlytics.com/onboard)
4.) You will get an app to download and run. The app walks through the steps of adding
A.) A build phase run script
B.) Code to the application main Crashlytics.startWithAPIKey(“nnnn”)
5.) Run your Xcode version of the app
The Crashlytics web page popped up immediately.

strange InvalidCastExceptions from NSObject to NSBundle/NSUserDefaults with mono runtime 2.10.12

I seem to be having some problems after updating Xamarin/Monotouch this morning.
I updated MonoDevelop to 3.06 from whatever version was current and stable 10 days ago (sorry I can't be more specific), and Xamarin Studio to 4.0.2. I've been using MonoDevelop exclusively and have opened Xamarin Studio only now, wondering whether or not I was encountering a MonoDevelop bug.
My current MonoTouch version is:
Xamarin.iOS
Version: 6.2.1.201 (Enterprise Edition)
Hash: ed9807c
Branch:
Build date: 2013-19-03 13:42:59-0400
In either IDE, when running my app in either release or debug mode in the Simulator my app crashes with following InvalidCastExceptions:
System.InvalidCastException: Unable to cast object of type 'MonoTouch.Foundation.NSObject' to type 'MonoTouch.Foundation.NSUserDefaults'.
System.InvalidCastException: Unable to cast object of type 'MonoTouch.Foundation.NSObject' to type 'MonoTouch.Foundation.NSBundle'
These aren't the sort of casts that I'd expect to have fail on me :-)
In any case, the app compiles, transfers and runs correctly on an iPhone 4 with iOS 6.1.2 when built and installed from either Xamarin Studio or MonoDevelop
I've set the runtime target to 2.10.12, 2.10.11 and 2.10.9 (via this new Runtime Target menu option in the menus, even though it's meant to have no effect), and each time the app crashes in the same way.
This is all on code that was working correctly before the update (last week, before I went off to Iceland for a holiday and nobody touched anything while I was gone)
We don't use any third party assemblies; I've cleaned and rebuilt all assemblies but that hasn't helped. I'm about to try to narrow the problem down in a small test solution.
UPDATE 1:
Looking at the assemblies' version numbers in MonoDevelop, I see:
Assembly Version 2.0.5.0, found in /Developer/MonoTouch/usr/lib/mono/2.1
Monotouch has an Assemlby Version of 0.0.0.0.
I created a new MonoTouch project and added the first offending line to its main method:
public class Application
{
static void Main (string[] args)
{
// My real App crashes on this line with an InvalidCastException:
string s = NSUserDefaults.StandardUserDefaults.StringForKey("Login");
UIApplication.Main (args, null, "AppDelegate");
}
}
This ran fine.
UPDATE 2:
After changing the Build Options of the test app to match what we have in our real app, I get the same crash. The build options we have are:
iPhone Build -> General -> Linker Options -> Link All Assemblies
iPhone Build -> Advanced -> Use SGen generational garbage collector
iPhone Build -> Advanced -> Use SGen generational garbage collector -> Use reference counting extension.
Disabling ("Use reference counting extension") allows both the test app and my real app to run without crashing. So the problem seems to lie there.
I've updated to Xamarin Studio 4.0.2 and MonoDevelop 3.0.6
So you updated MonoDevelop 3.0.6 to Xamarin Studio 4.0.2, right ? Sadly that does not tell us exactly which version of MonoTouch/Xamarin.iOS was used before/now.
The easiest way to get exact version information is to use the "Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details" button and copy/paste the version informations (you can use the "Copy Information" button).
Could you edit your question to add this ?
my app crashes with following InvalidCastExceptions:
Do you use pre-built assemblies ? If some were against MonoTouch 6.0.x (or earlier) then the strongname change (in 6.2.x) could result in two different monotouch.dll being loaded - and you won't be able to cast instances between them.
If everything is rebuilt from source (no 3rd party .dll that can't be re-compiled) could you try to make a small sample (e.g. by reducing/commenting parts of your app) to show exactly where this happens ? (if possible edit your question with the source or file a bug report).
I've set the runtime target to 2.10.12, 2.10.11 and 2.10.9
The installed system mono is a requirement to run Xamarin Studio and some tools. However application built by Xamarin.iOS does not depend on the system installed Mono. IOW Xamarin.iOS ships with it's own runtime and SDK libraries (e.g. assemblies).

Resources