EDIT: The issue is now solved, I'm including the details here to help anyone else who runs into this, as it's not that simple to solve.
Basically, it comes down to updating using the develop branch.
The first step is to checkout the monogame develop branch, this will not include the thirdparty/libs submodule, so you need to also update this in order to be able to compile the sources.
After this, you can compile MonoGame.Framework.Linux.sln, and update the references in your project to point to the new dll files.
This will still not load effect files, unless they are created using an up-to-date version of the content processors, so you need to go to a windows computer, checkout the develop branch (and libs) - or copy them from your linux system - then compile MonoGame.ContentPipeline/ContentProcessors/MonoGameContentProcessors.sln
You need to update the reference to MonoGameContentProcessors.dll in your content project, you also need to rename the MonoGame.ContentPipeline\ContentProcessors\bin\Release\libmojoshader_32.dll file to simply libmojoshader.dll.
Once all of this is done, you can finally use it as intended - build the .xnb files from your .fx files and add them to the linux project.
Hopefully this information will be useful to someone.
=================================================
Original post:
I have just started out with MonoGame, and am trying to get a very simple application (rotating cube) to work on Windows and Linux - windows is not proving to be a problem, but I am having trouble getting my .fx files to work on Linux.
I have set up a "MonoGame Content Project", added the .fx file to it, selected the "MonoGame Effect" processor, set the build configuration to Linux - this all seems to work and i get a .xnb file in the output directory.
When I set up the Linux project, I copied the .xnb to the "Content" folder (the root directory is set accordingly) and used the following code to load the effect (same code as on windows):
CubeEffect = Content.Load<Effect>("Effect1");
CubeEffect.CurrentTechnique = CubeEffect.Techniques["Technique1"];
This then results in an application crash with this error:
Microsoft.Xna.Framework.Content.ContentLoadException: Could not load Effect1 asset!
Initially i assumed this to be a problem with file names, directory names, or some incorrect setting. However, i tried adding a .png file to the content folder and loading that:
Texture2D Tex = Content.Load<Texture2D>("bg.png");
This works perfectly well (checked the properties of the Texture2D in the debugger, and it has correct details for the file).
Have i missed a step somewhere when converting the shader file? Is there some really obvious thing that I'm not seeing?
If not, does anyone have any clue why it would act like this, or some way to get a more detailed error from it, like an actual reason for it not being able to load the asset?
EDIT: Having looked at the point in the disassembly where it actually throws the error, it seems that it finds the file, but doesn't recognise it as any valid resource type - could this be some kind of version/compatibility issue?
This is a very common problem when trying to load shaders into Monogame.
I tried, and failed to be able to load my custom shader into the Monogame framework.
You need to compile from the develop3d branch, and not the official release. You also need to convert your HLSL shader into a MojoShader compatible syntax. Then you need to either load the effect from the Monogame Content importer (which needs to be configured manually), or add your shader as an embedded resource and load it into your project in order to use it.
I have never been able to actually pull this off myself. From my readings online, this particular part of the Monogame framework is not quite ready for primetime yet.
Here is some information on it. They really didn't provide much information on this as I suspect they know it is very problematic:
https://github.com/mono/MonoGame/wiki/Effects-And-Shaders
Related
I have created a custom control for my development team to utilize the CefSharp Chromium Web Browser. I have everything setup and working well. The only problem is having it run for projects that do not directly reference the chrome project in their solution.
I would like to find a way for when a developer drag and drops my custom control into their application, it will automatically copy ALL of the required files from the compiled control to their bin folder.
Currently, it only pulls the handle full directly referenced by the tool, but some are utilized at run time due to limitation of the utility for being able to compile for Any CPU efficiently.
Image of Files
I would like to have all of the files on the left hand side be copied automatically upon using the control from the tool box to the appropriate folder, or at the very least at run time.
Any information or ideas on where to look are greatly appreciated.
I managed to solve the problem, though this feels like back practice.
My issue what using CefSharp and getting all of the x64 and x84 files downloaded where ever require. I ended up adding a zip file of each content and then extracting them at run time as needed.
I've been trying to figure out why the content pipeline tool isn't allowing me to load textures and spritefonts.
My MainGame constructor:
public MainGame()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content"; //Content folder
_graphics.SupportedOrientations = DisplayOrientation.LandscapeRight;
_textureAggregate = new TextureAggregate();
}
This is the error (ContentLoadException: The content was not found):
Finally, my project folder structure:
Now, the defaultfont.xnb is being created by Content.mgcb to the ~/Content/bin folder, I've just copy-pasted it to /Content attempting to get the project to recognize at least this one file. Note that the stream is working just fine (but I don't know if that's the right way to load textures now?).
I'm looking for anything else that I might not know about that requires configuration in order to get my project to recognize these files.
You should not be adding the content into the Content folder. Instead, you need to open your content pipeline tool (Content.mgcb). You can add the textures you need there instead by clicking "Add Existing Item".
As is turns out, I didn't correctly remember the details of installing monogame and xamarin, and had created the project as an openGL game (the little icon is the same after creation on a compromised system so I thought nothing of it).
I blame this on having just redeployed my dev environments and had managed to install the monogame pipeline tool but none of the templates, so searches for the monogame project template type went nowhere but I could still create the content project in the Content folder.
I happened across all the same classes and objects I needed to do basic work without getting compile-time errors via nuget.
So, if anyone else is having a real hard time with this, make sure you installed MonoGame and are working with the templates and didn't mistakenly create an opengl game like this idiot :)
I am working on a project and while compiling, my laptop handed up and I have to turn it off manually.
After the restart I found that my code is not showing up. There is no line of code in program.cs file.
I am working on that code since a month. And all of it vanished.
Need help. I have the executable file working properly. But i need the code. Is there any way to find that code ?
Use ILSpy to decompile your executable. You will get the source code back, minus the comments. This is possible because assemblies (like your exe) actually contain "Intermediate Language" (IL), and not native machine code/assembler. From the IL it is possible to get a reasonable representation of the original source code. You may need to recreate the csproj file manually, if you do not have it.
If you have the .exe you must have compiled it, if you compiled it you must have saved it.
Where it is depends on where you saved it. Easiest thing would be to use the search function in Windows – search for whatever you called your program, or failing that, *.csproj. Then you can open the csproj file with Visual Studio and you should get most of it back.
I'll give you 2 versions of my problem to describe it, first the short version.
When I try to build my application it does that perfectly and my app works but when I try to rebuild it, that fails and gives an error message saying that 2 files are missing (bin/debug/MusicPlayer.exe and bin/debug/MusicPlayer.pdb). When I then try to build normally, it fails to with the same error.
Now the longer version:
The way this happened was quite out of nowhere, I program on 2 different locations (both in Visual Studio 2010 sp1) but to always have the recent version in the right place I copy the entire solution folder to a usb stick, this folder I copy over again on the other PC and use it to continue were I left off, I've done this many times without problem. Yesterday however, I got an exception while testing the app. But instead of showing this in my code, it was complaining that it could not find the program.cs file (it was there, but apparently it had a different checksum (md5) and it asked me to use this one. After a while I found what part of my code caused the exception and fixed it. Since then I haven't got that error anymore. But when I later tried to rebuild instead of build, it gave me the error described in the short version. I have tried to fix it, but apparently I was not very successful.
Basically, what I think it does is delete the files in the debug folder that need rebuilding and then gives me the error of missing files (the files that it deleted) and thus failing to rebuild succesfully because these deleted files the normal build option won't work to.
(What I then do is re-copy them from my usb to make the normal build work).
Don't know if it's important, but I program in C# and I'm still learning.
Also when I copied it to my usb I believe I had no errors and the app was working fine (except the part I fixed later, which I could not test at that location). And when I build the entire solution it gives some warning ==> "Assembly 'bun/debug/MusicPlayer.exe' is incorrectly specified as file" and this for 5 files.
Does anyone know how to fix this rebuild problem and if necessary the warnings?
Thanks in advance
(and sorry for my bad English)
OK it seems like you might be confusing yourself with your directory structure here. If you want to add Content or Resources (Images, Text Files, etc.) you should place them in a folder within your project (not called bin or obj). All your build files will go here. Instead place the Content in another folder and Right Click -> Properties and Set the build action to "Content" or "Resource" and set the Copy to Output Directory (bin folder) to "Do not Copy" or "Copy if newer."
The project is failing because you have the built executable "MusicPlayer.exe" in your project. So Visual Studio is trying to build an executable file in adding to the project. Restructure your directories or remove "MusicPlayer.exe" ever time your build your project.
Do you have any anti-virus software running? They can go way too aggressive on removable drives. You are actually continuously deleting and creating a runnable program on usb stick by recompiling.
Just a guess tho...
Sounds to me like you have a pre- or post-build event with a hardcoded path in it. Fix that using variables and it should be ok.
I've got licenses.licx file that is included to one of my projects properties. I am not sure how that is used by its dlls. Is it used by msbuild? Do you have any idea how it is used when the solution is building?
Since you indicate that StellarEleven's reply doesn't help, I guess you're looking for something even simpler. This is probably not 100% correct, but it is my understanding of how this works:
The licx file is simply a list of the "licensed" components used by your application.
Each line in the file is of the following format:
[Component Name], [Assembly Name]
For example one of my projects uses the licensed IP Works NetDial component so my .licx file contains the following line:
nsoftware.IPWorks.Netdial, nsoftware.IPWorks
In the context of the project (.csproj) file, the .licx file is referenced as an EmbeddedResource. During the build process, LC.exe verifies that the machine performing the build has the appropriate license(s) for the component in question, and generates a binary .licenses file which eventually gets embedded as a resource ([AssemblyName].exe.licenses) in the final executable.
Does this help?
Licenses.licx file woes
File this under ASP.NET, Department of WTF.
Frustration When you are developing a web application with our
controls, a mysterious file called licenses.licx appears. No, it's not
an order to use a weirdly-named lollipop, but is a transitional file
generated (and modified) by Visual Studio that participates in license
checking. In design mode, Visual Studio uses this file to make a note
of every licensed control you use in your design. When you then build
your application, Visual Studio read this licenses.licx file and for
every control mentioned there, will load the relevant assembly and run
the license code in that assembly to see if the assembly is properly
licensed (that is, that the product to which it belongs has been
properly installed on that machine). If everything checks out, Visual
Studio embeds the license key into the executable. If it doesn't,
you'll get weird error messages about the control not being licensed
(my favorite is "Could not transform licenses file 'licenses.licx'
into a binary resource." to which I usually invoke the colorful
language of my ancestors).
Licenses.licx is actually a file in your solution (if you cannot see
it there, click Show All Files). Visual Studio uses a program called
lc.exe to compile the licenses into embedded resources in your
application, and when things go wrong with the license compiling I've
seen error messages that reference this executable as well.
Here's an example of a line in a licenses.licx file.
DevExpress.XtraCharts.Web.WebChartControl,
DevExpress.XtraCharts.v8.2.Web, Version=8.2.4.0, Culture=neutral,
PublicKeyToken=9b171c9fd64da1d1
The first value in this comma delimited list is the class, the second
is the assembly where it's found, and the other values are the rest of
the assembly's strong name. I'm sure you can see problems already,
especially when you upgrade a solution to the latest versions of the
third-party controls you use. If you want, you can edit this file and
remove the strong name parts with no problem.
But that's not the biggest issue with licenses.licx. The thing is
Visual Studio has a propensity of touching this file if you open the
solution (that's "touching" as in changing the file date to the
current date/time). This plays havoc with licensing, especially if you
happen open the solution on a non-licensed machine and you are using
source control. Suddenly your build machine will throw off these
"cannot transform" messages and you're left wondering what went wrong.
Another prevalent issue is when you have a team of developers working
on a solution: they're all unconsciously "modifying" this file.
So, the answer seems to be not to put the licenses.licx file under
source control. (KB article)
But this solution to the problem throws another red flag: if one of
the developers in a team adds a new control that needs licensing to
the form, a line gets added to his local licenses.licx file and it may
not get reflected in source control. Bam, your build machine fails the
build and Joe, who added the control, has to buy doughnuts for the
team until someone else breaks the build.
I'm afraid I have no good solution to this latter issue, because
unfortunately the "not putting licenses.licx in source control" seems
to be the way everyone is solving the licensing problem. Another
solution is to delete the licenses.licx file altogether and then get
Visual Studio to regenerate it by opening the solution (although this
is a bit difficult on a build machine).
Anyway, hope that all helps in some way. And hitting your laptop with
a phone isn't really going to help.
We use a custom check-in policy (TFS) that explicitly nulls the contents of this while if present in the check-in list.