akusei Posted April 20, 2010 Posted April 20, 2010 I'm trying to get ufmod to work with c#. I've followed their example and it works perfect! The problem is that if I add any images or icons to my c# app and compile those resources into the it with the build script then the application crashes every time.I think it might be because the final link with the .res file which contains the .xm overwrites the previous images resources... maybe? Anyway, I'm lost and can't think of anything else to do. Does anyone have any experience with this? Here is what I'm doing:1. Compile my .net resources with "resgen /compile MainForm.resx" which creates MainForm.resources2. Run build.batMainForm.resources contains the .net app icon and an image for the form.build.bat@echo offrem Build a mixed standalone CLI/C++ uFMOD examplerem *** CONFIG STARTSET VC_ENV=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.batSET CSC_HOME=C:\Windows\Microsoft.NET\Framework\v4.0.30319SET LNK_HOME=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\binrem *** CONFIG ENDif not exist "%VC_ENV%" goto Err1if not exist "%CSC_HOME%\csc.exe" goto Err2if not exist "%LNK_HOME%\link.exe" goto Err3call "%VC_ENV%""%CSC_HOME%\csc" /res:MainForm.resources /target:module /addmodule:cliwrapper\i_ufmod.netmodule *.cs"%LNK_HOME%\link" /LTCG /CLRIMAGETYPE:IJW /ENTRY:CCDKeygen.Program.Main /SUBSYSTEM:WINDOWS /ASSEMBLYMODULE:cliwrapper\i_ufmod.netmodule cliwrapper\i_ufmod.obj cliwrapper\ufmod.obj MainForm.netmodule mini.res kernel32.lib winmm.libgoto TheEnd:Err1echo Couldn't find the Visual Studio environment batch file:echo %VC_ENVgoto TheEnd:Err2echo csc.exe not found in %CSC_HOME%goto TheEnd:Err3echo link.exe not found in %LNK_HOME%:TheEndpause@echo onclsmini.res is the resource file which contains the .xm dataIt will crash with the above configuration. If I remove the .resources from the batch file and remove the references to the resources in code then no crash happens. Any help would be greatly appreciated.-akusei
Accede Posted April 20, 2010 Posted April 20, 2010 Is you version VC++ 2008 or higher if yes i thing you most remove this // Remove CRT dependency in VC++ 2008#pragma warning(disable:4483)You sure you us the bsp:c#// C++ wrapper for embedding unmanaged uFMOD code in .NET// NOTE: ufmod.obj should be compiled in UNICODE flavour!if you us this bsp:c# how is on the ufmod folder then us this bat file.@echo offrem Build a mixed standalone CLI/C++ uFMOD examplerem *** CONFIG STARTSET VC_ENV=C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.batSET CSC_HOME=C:\Windows\Microsoft.NET\Framework\v2.0.50727SET LNK_HOME=C:\Program Files\Microsoft Visual Studio 9.0\VC\binrem *** CONFIG ENDif not exist "%VC_ENV%" goto Err1if not exist "%CSC_HOME%\csc.exe" goto Err2if not exist "%LNK_HOME%\link.exe" goto Err3call "%VC_ENV%""%CSC_HOME%\csc" /target:module /addmodule:cliwrapper\i_ufmod.netmodule test.cs"%LNK_HOME%\link" /LTCG /CLRIMAGETYPE:IJW /ENTRY:Program.Main /SUBSYSTEM:WINDOWS /ASSEMBLYMODULE:cliwrapper\i_ufmod.netmodule cliwrapper\i_ufmod.obj cliwrapper\ufmod.obj test.netmodule mini.res kernel32.lib winmm.libgoto TheEnd:Err1echo Couldn't find the Visual Studio environment batch file:echo %VC_ENVgoto TheEnd:Err2echo csc.exe not found in %CSC_HOME%goto TheEnd:Err3echo link.exe not found in %LNK_HOME%:TheEndpause@echo oncls
akusei Posted April 20, 2010 Author Posted April 20, 2010 (edited) I'm not sure what you mean by bsp:c#?? I am using Microsoft Visual Studio 2010 and compiling the application with .NET framework 4.0. I am using the ufmod modules that came with ufmod, I did not recompile them and my app was written in C#. I am also using the .bat file from the example but I have modified it to work with my application.I had to modify the bat file because my app has more than 1 .cs file and has resources. Also, I'm not sure where you want me to put "#pragma warning(disable:4483)", as I am not receiving any compile-time or link-time warnings.thanks,akuseiedit: my problem occurs at run-time, the application crashes because it tries to access non-existent resources. Those resources should be there because I compiled them in, but for some reason they are not. Edited April 20, 2010 by akusei
EmberTheVulpix Posted April 20, 2010 Posted April 20, 2010 (edited) akusei, I've only gotten ufmod to work in C# by recompiling ufmod as a DLL and using DMex by UFO-Pu55y to load the DLL from memory and map all the exports. I think there is an example about using DMex with ufmod to play music all from .NET resources in the DMex thread. Edited April 20, 2010 by EmberTheVulpix
akusei Posted April 20, 2010 Author Posted April 20, 2010 (edited) akusei, I've only gotten ufmod to work in C# by recompiling ufmod as a DLL and using DMex by UFO-Pu55y to load the DLL from memory and map all the exports. I think there is an example about using DMex with ufmod to play music all from .NET resources in the DMex thread.this will work quite nicely, thanks!-akuseiedit: unfortunately it doesn't work... I can't get dmex to load the DLL and so I tried to just drop the file to the filesystem and load it from there and it starts to play the music but stutters in an endless loop and freezes the app. I'm about to give up on this one! Edited April 20, 2010 by akusei
EmberTheVulpix Posted April 21, 2010 Posted April 21, 2010 drop the file to the filesystem and load it from there and it starts to play the music but stutters in an endless loop and freezes the app.This also happened to me when using p/invoke. Very confusing as to why this is happening. It only worked when I used DMex. Anyways, looks like UFO-Pu55y replied with a fix for it.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now