ContentLoadException problem - xna

I'm very new to XNA. Actually I have XNA 4.0 book by kurt jaegers, so i installed VS 2010 and XNA 4.0 and wrote my first program. But that program didn't run successfully,it kept displaying the ContentLoadException file not found. So i did a bit of research on web and found that there is some issue with XNA 4.0. So I uninstalled the VS 2010 & XNA 4.0 and installed VS 2008(express edition) & XNA 3.0 . Then I compiled my first program on it and i ran successfully.
But,now I'm facing the same problem again with my new projects. I've tried both Syntax :
xx = this.Content.Load<Texture2D>("TitleScreen");
xx = Content.Load<Texture2D>(#"TitleScreen");
And there is no spelling mismatch problem. Please Mods guide me. And please tell me why I'm getting this problem again and again.
System Specs :
XP sp3,i3,2gb RAM.

Content that you want to load into via the ContentManager needs to be in the content project. Pretend for a moment it looks like this
Mygame.Content > SomeFolder > textureName
You would use content.Load<Texture2D>("SomeFolder/textureName") to get to it. If it was at the root of the Content project content.Load<Texture2D>("textureName") will work. If (and since) it isn't there are 2 things to check
Right click on the texture and go to properties. Look at the AssetName properties. This is what you use to load it up via the Content Manger. Try using whatever this name is.
The root directory the Content Manager looks in is "Content". Look at Content.RootDirectory and see what it is. If it isn't "Content" change it to that. That could also work.

In order to properly load content, you'll need to use the generic method
ContentManager.Load<T>
For example, if you're trying to load a Texture2D element, Use the following syntax:
Texture2D texture = Content.Load<Texture2D>("textureName");
Read more about loading content in this link.

There is a known issue with ContentManagers instanced by anything other than the default Game object constructor, which cause the problem you are experiencing.
If you are indeed using a ContentManager object other than the one supplied on the Game object, the solution is:
When you instantiate the ContentManager, you should set it's RootDirectory property to
#"Content"
Hope it helps

Related

Xamarin NetStandard Android sfChart DateTimeStripLine not displayed?

This is fairly specific (as the title suggests).
I've recently ported my Xamarin Forms app to NETStandard, and now my sfChart DateTimeStripLine are not visible on Android.
Things show up more-or-less fine on UWP, so I don't think I've introduced regressions.
Anyone else having similar experiences? Has anyone successfully used ChartStripLine on NET Standard?
We have prepared a sample using DateTimeStripline in SfChart with .Net Standard 1.3 and it’s working fine in this sample. If still you face the problem, please provide Stripline related code snippet, it would be helpful to provide better solution.
So, finally figured out the issue:
The StripLines declared in XAML work fine, but binding to a StripLineCollection did not (android only). Unfortunately, declaring in XAML is not a particularly useful option.
To fix/workaround, declare StripLine in XAML like so:
<chart:DateTimeAxis x:Name="TheTimeAxis" ...>
<chart:DateTimeAxis.StripLines>
<!-- Empty def requires at least one item to be used
This creates container to fill in ViewModel.
Fixes dissappearing StripLines bug on android -->
<chart:DateTimeStripLine WidthType="Day" Width ="1"
Start="09/28/2017">
</chart:DateTimeStripLine >
</chart:DateTimeAxis.StripLines>
Then, in the code behind access the named axis, pull out the striplines and modify to your hearts content.
// Workaround Android: Our StripLines do not appear to be
// refreshing when bound from XAML. To fix we create in XAML,
// then retrieve the existing collection and pass that to the
// viewmodel for modification
DateTimeAxis sl = this.TheTimeAxis;
var slc = sl.StripLines;

How to localize UI files in PySide

I created an application which loads its UI dynamically from UI files (added to resources of application. I have't translate in with poyside-uic, loading as is. now I want lo localize application, but do not understand how.
I tried to generate TS file using pyside-lupdate widge1.ui widget2.ui ... -ts my.ts and got document with multiple context nodes and linguist does not shows all records (only about 7 records and I do not understand which exact).
So, my question: how to translate dynamically loaded UI files?
Found it. Quite simple, but not always obvious.
Execute pyside-lupdate file1.ui file2.ui .... fileN.ui -ts translations\ru_RU.ts. Got a TS file after that with multiple contexts (it is ok, I was wrong)
Open TS with linguist. Ensure that option 'Context' checked in menu "View->View"
...
PROFIT!!!

How to use sc_static() while programming

I am trying to display some Images which are in my local folder. I am getting the image name from a server through JSON. Based on that, I am constructing the Image path dynamically. However, the final image path will be changed by SC build tools. I know that we can use sc_static() in css or view's specifications to map it to the final path. How can I achieve that mapping (to final path from local path) while programmatically constructing my url.
Any ideas, suggestions and thoughts?
sc_static is not a javascript function, but rather a convention used to tell Abbot (Sproutcore's build tool, written in ruby) to replace it at runtime with a path pointing to the resource passed as first argument to sc_static.
Note that this substitution is done by Abbot when the page is refreshed (in dev mode) or when the app is built (in prod mode). It is not a js function at all (use Chrome inspector to see it by yourself).
If you want to use sc_static in JS you can define all resource references as such:
YourApp.loadingIcon=sc_static('loading.png');
YourApp.greenIcon=sc_static('green.png');
and then reference the
YourApp.loadingIcon , YourApp.greenIcon
variables in your code.
Finally I found the answer with the help of my friends. sc_static is not javascript function it is a function targeted for build tools(Abbot) of Sproutcore to replace the actual production path after build. Hence we can not use sc_static in programming.
If we want similar function we have develop our own.

XNA File Load

In XNA, how do I load in a texture or mesh from a file without using the content pipeline?
The .FromFile method will not work on xbox or zune. You have two choices:
Just use the content pipeline ... on xbox or zune (if you care about them), you can't have user-supplied content anyways, so it doesn't matter if you only use the content pipeline.
Write code to load the texture (using .SetData), or of course to parse the model file and load the appropriate vertexbuffers, etc.
For anyone interested in loading a model from a file check out this tutorial:
http://creators.xna.com/en-us/sample/winforms_series2
This is a windows only Way to load a texture without loading it through the pipeline, As Cory stated above, all content must be compiled before loading it on the Xbox, and Zune.
Texture2D texture = Texture2D.FromFile(GraphicsDeviceManager.GraphicsDevice, #Location of your Texture Here.png);
I believe Texture2D.FromFile(); is what you are looking for.
It does not look like you can do this with a Model though.
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.texture2d.fromfile.aspx
If you really want to load an Xna Xna.Framework.Graphics.Model on PC without the content pipeline (eg for user generated content), there is a way. I used SlimDX to load an X file, and avoid the parsing code, the some reflection tricks to instantiate the Model (it is sealed and has a private constructor so wasn't meant to be extended or customised). See here: http://contenttracker.codeplex.com/SourceControl/changeset/view/20704#346981

ASP.NET MVC ViewData (using indices)

I had a working solution using ASP.NET MVC Preview 3 (was upgraded from a Preview 2 solution) that uses an untyped ViewMasterPage like so:
public partial class Home : ViewMasterPage
On Home.Master there is a display statement like this:
<%= ((GenericViewData)ViewData["Generic"]).Skin %>
However, a developer on the team just changed the assembly references to Preview 4.
Following this, the code will no longer populate ViewData with indexed values like the above.
Instead, ViewData["Generic"] is null.
As per this question, ViewData.Eval("Generic") works, and ViewData.Model is also populated correctly.
However, the reason this solution isn't using typed pages etc. is because it is kind of a legacy solution. As such, it is impractical to go through this fairly large solution and update all .aspx pages (especially as the compiler doesn't detect this sort of stuff).
I have tried reverting the assemblies by removing the reference and then adding a reference to the Preview 3 assembly in the 'bin' folder of the project. This did not change anything. I have even tried reverting the Project file to an earlier version and that still did not seem to fix the problem.
I have other solutions using the same technique that continue to work.
Is there anything you can suggest as to why this has suddenly stopped working and how I might go about fixing it (any hint in the right direction would be appreciated)?
We made that change because we wanted a bit of symmetry with the [] indexer. The Eval() method uses reflection and looks into the model to retrieve values. The indexer only looks at items directly added to the dictionary.
I've decided to replace all instances of ViewData["blah"] with ViewData.Eval("blah").
However, I'd like to know the cause of this change if possible because:
If it happens on my other projects it'd be nice to be able to fix.
It would be nice to leave the deployed working code and not overwrite with these changes.
It would be nice to know that nothing else has changed that I haven't noticed.
How are you setting the viewdata? This works for me:
Controller:
ViewData["CategoryName"] = a.Name;
View:
<%= ViewData["CategoryName"] %>
BTW, I am on Preview 5 now. But this has worked on 3 and 4...
Re: Ricky
I am just passing an object when I call the View() method from the Controller.
I've also noticed that on my deployed server where nothing has been updated, ViewData.Eval fails and ViewData["index"] works.
On my development server ViewData["index"] fails and ViewData.Eval works...
Yeah, so whatever you pass into the View is accessible in the View as ViewData.Model. But that will be just a good old object if you don't do the strongly typed Views...

Resources