Mononame is not generating Debug.xnb - c#

Today im having issues with the Monogame content pipeline, I tried building a .spritefont file, it did not throw any errors when building, but I get the following error when I run it:
Microsoft.Xna.Framework.Content.ContentLoadException: The content file was not found. ---> System.IO.FileNotFoundException: Could not find file "/home/unrhypercam/Monogame/Engine3/Engine3/Engine3/bin/Debug/Content/Debug.xnb"
As far as I know, this file is supposed to be generated automatically,
I also did not use the normal content pipeline, but the MGCB editor provided by Monogame
I cant seem to find anything on the subject, any info would help
Edit: I fixed the content pipeline, and it is not the problem, any help would be appricieated

You are correct in guessing that .xnb files should be generated automatically in your folder. I am assuming this exception is being thrown only at your code, and the Content Pipeline builds all your content without any errors. This can be due to that fact that the path to your content file inside your code is different than the path the content file is actually being exported to.
You should check inside the \bin folder inside the folder your Content.mgcb file is, and compare the path of your "Debug.xnb" file to the one you are using in the code. Since the content pipeline's export path can be easy to mess up, it's better to check in the \bin folder and correct the path inside your code

Related

How to access a subfolder within a asp.net (C#) Project, WebApi

I have a seemingly basic question, but I can't access a folder inside my project (actually, it is a project that is one of the references of the main project), which is a folder called "pdfs" that contains 1 PDF that I want to convert to base64.
I put the "pdfs" folder in the same level of the file from where I call it, as I thought it would be easier to access (actionDB.cs file, which is in services/actions/actionDB.cs). The "pdfs" folder is in services/actions/pdfs).
But there is no way to get the correct path of this folder.
On the contrary, if I put the folder in c: , getting path = "c:\\pdfs", and the pdf file there, I can easily find it and convert the pdf perfectly in the code.
Any idea how to access these folders that are inside the projects, as if they were assets? I already put 'copy always: to the destination' and 'type of compilation: content' in the pdf properties, but I still can't access it.
I have already tried the following options:
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), #"pdfs");
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), #"services\actions\pdfs");
string path = Path.Combine(Path.GetDirectoryName(Environment.CurrentDirectory), #"services\actions\pdfs");
The namespace of the actionsDB is ProjectName.Data.services.actions.
I got results such as IIS/.., or other paths inside VS installation…, Assembly and some weird hashes.
Nothing works...
Could you help me with this?
Thank you very much,
CBD
AppDomain.CurrentDomain.BaseDirectory is probably the most useful for accessing files whose location is relative to the application install directory.

Any reason why a try catch exception would report a file path wrongly in SSIS?

So I have this SSIS package that has a script task that is copying files to a destination and then putting their data into C# data structures to parse later. However, it runs through the first file and then suddenly I get this exception from a try catch in my main method stating:
Error: 0x12 at Copy xxx Files to New Destination, there was an exception :<
which said: : Could not find file 'C:\Program Files\Microsoft SQL
Server\130\DTS\binn\xxx370xxxxx_xxx.rpt'.
the thing that caught my eye is that the file path changed from a different place, I don't store anything in the sql server binn folder...
Question:
Could the file path it's trying to read from not be the Bin file and that exception is reporting this folder because of some underlying reason,
in addition
Have any good advice for debugging a broken package with C# script tasks?
I am new to this project and don't have much to lean on for figuring it out and debugging C# code in BIDS is seemingly very not intuitive. (doesn't hit breakpoints, can't step through my c# code.)
Posting this as proposed answer, said below by Martin Smith:
It won't be making it up. Your code is trying to find a file there. I would imagine that C:\Program Files\Microsoft SQL Server\130\DTS\binn is a default working folder location and somewhere you are just using a file name instead of a full path.

WPF How to modify resource/content file inside my project folder at runtime (NOT in bin directory)? Implementing "Recent changes" section

I would like to modify the contents of a file placed in my project folder (Specifically "Assets/recentChanges.txt") at runtime. Let's say it contains information about recent changes in application. It is supposed to be read and bound to a textbox control, which later on can be edited by developers and saved back. The problem with content files is that they are copied to output directories and therefore I'm not editing the original file in Assets folder, but the one in bin/Debug/Assets/ folder. And the Embedded Resource build action is not an option since such files cannot be modified.
The question is: how can I modify mentioned .txt file in its original root/Assets/recentChanges.txt location during runtime? All of the below instructions point to similiar build-dependant path:
Environment.CurrentDirectory;
Assembly.GetExecutingAssembly().Location;
Or, in other words, what would be the correct approach for implementing "Recent Changes" section with following conditions:
based on text file in its original project location
possibilty to modify the file at runtime through UI
file copied to the output folder and visible to the user (through textbox) in published application
I am aware that it's probably not the perfect approach, because "recent changes" info could be collected from database or the .txt file could be modified manually and then copied to output locations... but nevertheless I think the issue is somewhat confusing and I would love some help. Thanks!
The compiled and running application doesn't know anything about some "original" location. This location is only important to Visual Studio when the application is built.
If you want to modify the file in this folder you should specify an absolute path to it, i.e. "c:\your_project_folder\file.txt".
The .exe cannot be supposed to know from where it was compiled

WPF can't find part of path in ShadowCache

I have an image in a Asset class library project. The build action is Content and the Copy to Output Directory setting is Copy Always because I want to be able to allow users to replace these files without my intervention.
The problem is, I'm getting a design-time error (everything works find on compile and run) that says "Could not find a part of the path 'C:\Users\Name\AppData\Local\Microsoft\VisualStudio\12.0\Designer\ShadowCache\oreaxsnr.cjd\orsr3pqd.wnf\Images\TestImage.jpg'."
I'm using Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); to get the path of the assembly, and then I concatenate that with a \\Images\\TestImage.jpg string. Thinking that was the source of the problem, I commented out everything related to getting that image, cleaned the solution, and rebuilt. It still has a problem with finding part of the path.
I went to the orsr3pqd.wnf folder and there's the class library .dll that calls the image, and nothing else. I deleted all of the ShadowCache folder after closing Visual Studio, restarted VS2013, and it immediately put two folders in the ShadowCache folder.
Maybe it's thinking there's supposed to be a resource in the .dll, even though I'm setting the build action to Content? Any direction would be helpful.
You should be able to reference it straight from the XAML if it is in a project that is part of the application like this:
<Image Source="/AssemblyName;component/Images/TestImage.jpg" />
If that doesn't work, then this should:
<Image>
<Image.Source>
<BitmapImage UriSource="pack://application:,,,
/AssemblyName;component/Images/TestImage.jpg"/>
</Image.Source>
</Image>
If neither of these work for you, then I'd also suggest setting your image file Build Action to Resource, rather than Content.

Runtime error 'Could not find a part of the path'

I'm programming in c#, trying to read text from a file to create a map for a game that I'm making, but for some reason I keep getting the following error:
Could not find a part of the path
'F:\TiledLevel01\TiledLevel01\bin\x86\Debug\Content\Map.txt'.
Can anyone tell me where I may be going wrong? Thanks in advance!
Presumably that file exists in your project, so highlight the file in Solution Explorer, hit F4, and set its Build Action to Content. That will copy the file to the output folder on build.

Categories