XNA error - file not found - xna

I am working on XNA with XML reading. While I'm debugging the code its shows file not found error, but I added my XML file in Content reference folder. While I'm using this code I got the error.
System.IO.Stream stream = TitleContainer.OpenStream("ProductSchema");
Thanks in advance.
Bharathi.G

Shawn explains this very well in this post: Shawn's blog entry

Try adding the extension:
System.IO.Stream stream = TitleContainer.OpenStream("ProductSchema.xml");

Check whether that file is present in the bin folder where your game .exe file lives (bin\Windows Phone\Debug\Content). If not, then this may be the problem. To solve this :
right click the file >> select property >> change build action to None and copy to output directory to Copy if newer.
This works for me while loading/reading binary files in my game.

Related

Module build failed (from ./node_modules/#ngtools/webpack/src/index.js):

I have created an application on angular 7 and ionic 4.
I tried to edit app.routing.ts file, setting path and component. From then on I am getting this error below:
ERROR in ./src/app/department/department.module.ts
[ng] Module build failed (from ./node_modules/#ngtools/webpack/src/index.js):
[ng] Error: ENOENT: no such file or directory, open 'C:\Users\x\department\department.module.ts'
[ng] at Object.openSync (fs.js:436:3)
[ng] at Object.readFileSync (fs.js:341:35)
[ng] at Storage.provideSync (C:\Users\x\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:98:13)
Make sure department component exist, check the templateUrl that corresponds to the file name you are referencing. You may have also modified the path unknowingly during modification of app.routing.ts file.
C:\Users\x\department\department.module.ts
This error occurs when your component can't be found with your app.module settings.
Follow these steps to solve your problem:
Check if the module.ts file exists.
Check the relative path.
The path is case sensitive (maybe the .ts file is Department).
Both answer are useful from #trustidkid and #vinay sharma. If there is someone has been facing the same problem;
1-Go to to the file that the error has occurred in. (To go directly to the file, click the error line shortly [CTRL+Click] (CMD+Click on MacOS):
ERROR in ./src/app/department/department.module.ts
Then check the path address if it is exactly true pointing the file. Most of these problems are having similar solutions. Just be sure about the path address of the file you want to point and the address mentioned in the other file which the error occurred.
This problem happens when you delete a component but forgot to delete its import from module.ts.
For example: TestComponent is deleted so you have to also delete:
import { TestComponent } from './test.component'
If you have a folder mapping on a windows machine like me, do not try to build it from a mapped folder, go to the original folder and build it from there.
Mapped Folder has a small icon like this:
In my case I had prime ng version that did not support a particular module, I simply commented it out and it worked.

how to replicate "WEB-INF/resources/apps/xbl/orbeon/us-state"

I try replicate the example with file "zip-states.xpl" in diretory "WEB-INF\resources\apps\xforms-sandbox\services" and files directory /WEB-INF/resources/apps/xbl/orbeon/us-state.
In my case, the first file (zip-states.xpl),I changed the value from select="doc('/xbl/orbeon/us-state/states.xml')/states/state to select="doc('/xbl/orbeon/colombia/states.xml')/states/state.
After, I copied the files from "apps/xbl/orbeon/us-state" to "apps/xbl/orbeon/colombia", and change file name us-state.xbl to colombia.xbl
In file colombia.xbl, I changed value from "src="oxf:/xbl/orbeon/us-state/state.xml" to src="oxf:/xbl/orbeon/colombia/state.xml" and I go to the test form , but its not working.
I try created the same case, for change the value in state.xml for colombia states but in other file.
Please, I hope you can help me
Many thanks.

Zipping a folder

I am trying to use
TZipFile.ZipDirectoryContents()
Like so:
TZipFile.ZipDirectoryContents('Test.PCF', WorkingDir);
If I am reading this right, it should save the contents of folder "workingdir" into a file named Test.pcf.
Now when I do this I get error::
Raised exception class EFOpenError with message Cannot open file
...test.pcf. The process cannot access the file because its being used by another process."
Two things confuse me:
It says that it cannot open file. There is no test.pcf yet. I was hoping this would create it.
It says cannot access file. Is this because it's not created yet? Am I using this function wong? If so how would I create a zip file from a folder location?
I tested your code and it failed in the same way as you reported.
I then created an empty zip file manually by running WinZip.
Then ran your code and it ran fine.
It appears that the zip file has to already exist for ZipDirectoryContents to work.
To create a zip file programatically:
myZipFile := TZIpFile.Create;
myZipFile.Open('c:\myfolder\newzipfile.zip', TZipMode.zmWrite);
myZipFile.Close;
myZipFile.Free;
This line will then work:
TZipFile.ZipDirectoryContents('c:\myfolder\newzipfile.zip', WorkingDir);

ILASM does not set FileVersion

I have an .il file which I can compile without any problems. I can strong name it and so without any issues. But I am not able to set the file version via the attribute as I would expect it. How can I set the FileVersion for an assembly when using ilasm?
If I do a round trip I get always a .res file which does contain only binary data which is not readable. What is inside this res file and can I edit it?
The code does not work
.assembly myAssembly
{
.custom instance void [mscorlib]System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = { string('1.2.3.4') }
The issue can be solved by using the .res file. It is not sufficient to do a round trip with ildasm and ilasm. The IL file does not reference the .res file. I had to add it to the ilasm call manually. The data in the res file seemed to contain the infos which are written into the PE header which is ok for me.
The final command line needed was
ilasm test.il /dll /res:test.res
I still do not know what exactly is inside the res file but I can exhange it with the meta data information of any other assemlby that I create manually and then decompile it to replace the metadata of the original assembly as I need.
It seems not many people are doing such stuff.

system.io.directorynotfound -> But it works in Console

My files are referenced like so (it's all relative):
// WHERE YOU KEEP THE PAGE TITLE XML
public static string myPageTitleXML = "xml/pagetitles.xml";
and
using (StreamReader r = new StreamReader(myPageTitleXML))
{ //etc.. . .etc....etc..
}
I get system.io.directorynotfound, and "this problem needs to be shut down", when I double click the executable. But running it from the console works like a charm. What's wrong here?
I played around with attempting to set Environment.CurrentDirectory but couldn't get anything to work. Why should I have to do that anyway? It defeats the purpose of a relative path no?
responding.. .
"application" does not exist in the current context, i'll keep trying what people have mentioned, this is not a windows.form
testing
Path.GetDirectoryName(Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase), myPageTitleXML); gives error URI formats are not supported, as does Path.GetFullPath(). Server.MapPath results in an error as well, this is currently offline
Well assuming this directory is somewhere under the directory in which your code is executing, it sounds like you can use ..
Application.ExecutablePath()
or
Application.StartUpPath()
.. to get an idea as to what your application is seeing when it goes in search of an 'xml' directory with the 'pagetitles.xml' file in it.
If the directory returned by one of these methods does not point where you thought it did, you'll need to move the location of your application or the location of this folder so that it is within the same directory as the app.
Hope this gets you on the right path.
So, when you run it from double clicking the executable, is there a file named pagetitles.xml in a folder named xml, where xml is a folder in the same location as the executable?
It's certainly possible to use relative paths like this, but I wouldn't really recommend it. Instead, maybe use something like:
string fileToOpen = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase), myPageTitleXML);
using (StreamReader r = new StreamReader(fileToOpen))
{
//etc.. . .etc....etc..
}
Is this ASP.NET code? If so then you probably need to do MapPath("xml/pagetitles.xml")

Resources