DirectX application on 64 bit windows - c#

I am developing a WPF application where the 3D part is handled by DirectX 9 (a lot of 3d that did not run fast enough using WPF).
The problem is the application is released with "Any CPU" as configuration and when a user runs it on a 64 bit windows, the direcX part crashes (System.BadImageFormatException). Apparently the dlls included for the directX part is not usable on a 64 bit windows.
This has happened with some other 3:rd part dlls that we use in our application but this we have solved by changing the dlls in runtime to the ones built for x64 if the user are running on a 64 bit windows machine. Do any of you know where I can find DirectX 9 dlls for x64? If they exist at all.
The ones I need are:
Microsoft.DirectX.Direct3D
Microsoft.DirectX.Direct3DX
Microsoft.DirectX
If they do not exist, can the problem be solved in some other way? I cannot change the configuration to x86 because the application is released via ClickOnce and a change of configuration make ClickOnce stop working (the configuration is included in the ClickOnce key)
Let me add that the I am using a Winforms part hosted by the WPF application and that the winforms part is using the DirectX dlls I am asking about. This was a much better and faster way of presenting a lot of 3D meshes in WPF than to use WPF:s 3D. Unfortunately this problem occurred instead.

The DLL's you need are for Managed DirectX. Unfortunately Microsoft no longer supports Managed DirectX and it's successor, XNA does not support 64bit either.
SlimDX is an open source alternative to Managed DirectX, and it supports 64bit. The other option is to write the DirectX code in unmanaged C++.

You can set your WPF application to only run as a 32-bit app. Post your ClickOnce problem as another SO question. This is probably your best option.
Project Properties -> Build -> Platform Target -> x86

Related

should i use mono to develop linux app

I have years of experience developing on microsoft development stack primarily visual studio 2012/c#. But right now, im required to develop app on linux. While i know c++, its been years since i really touch that. I have few questions.
Can i develop using mono and compile binary for linux and windows with no code(or minimal) code changes?
Can i develop on windows platform using visual studio 2012, compile for linux on window platform? do i need to use virtual machine for compiling for linux in windows platform?
How do you setup your development environment if you want to develop linux app on windows platform(develop on windows, compile for linux and windows. my linux box use for testing is a separate machine.)
Some info on what im working on.
My project is about network channel analysis. The client is cheap industrial linux box most probably with no ui. Im using mono/c# to develop the client. The server would be windows develop using vs2012 c#. Most probably using wpf as ui. Im planning to share network/communication library between linux(client) and windows(server). My primary concern for using linux is for cost saving since the client is almost thousand units.
thank you.
Mono runs executables in PE (Portable Executable) format, the native file format of Windows. There's no need to "compile for Linux", as long as your app is pure MSIL. And even if you use native DLLs through p/invoke, Mono and Wine work together to run the Windows files on Linux.
(The a.out and ELF executable formats used by native Linux applications don't have mechanisms for storing .NET metadata, the PE format was modified to support .NET, so that's what .NET Framework (not Micro Framework) implementations use regardless of platform)
The most important things to consider at the beginning are,
WinForms of Mono is problematic. Not only most third party controls won't work properly, but also libgdiplus itself is not 100% compatible with Microsoft's GDI+. It might appear to be a sweet option, but later you might still need to fight hard against the incompatibilities.
WPF is not an option as Mono does not support it yet.
GTK# is your best choice for UI, which blends naturally with Linux distros. If you refactor your Windows project properly, you should be able to share the non-UI code between your Windows and Linux solutions. This is what Mono guys recommend (not only use native UI frameworks for Windows, Linux, but also for Mac/MonoMac, iOS/Xamarin.iOS, and Android/Xamarin.Android).
So go back to your questions,
You should never wish for no code change for a real world project. No, that's impossible. As I said earlier, you have a chance to share most non-UI portion.
You can develop the non-UI portion and the Windows only portion using VS2012 and test them out on Windows. If you plan to use Mono's WinForms or GTK#, you must develop and debug on Linux using MonoDevelop. Thus, you need either a virtual machine or physical machine of Linux.
For me, I frequently switch between Linux/MonoDevelop and Windows/VS.
As Mono + C# is much more productive than using C/C++, many successful Linux apps are developed on Mono, such as Banshee and Tomboy.
You can use Visual Studio without problems but for example you cannot use WPF, while Windows Forms are ok. For more information what you can use visit: http://www.mono-project.com/Compatibility
Moreover there exists Mono tools which integrates with VS: http://www.mono-project.com/GettingStartedWithMonoTools

Compile C# on a (not for) Windows 8 ARM Tablet

Would it be possible to code and compile C#, on a Windows 8 Tablet (WinRT) (the ARM processor edition)?
Basically it comes down to this:
Is there a C# compiler that runs on ARM?
Is there and IDE that can run in WinRT?
If the above is true, I don't see any issue, but I currently can't find if the C# compiler runs on ARM (only a lot of posts about compiling for ARM). I've also looked at SharpDevelop, and found that their source code compiles for "Any CPU", which according to this post: Windows RT and c#, means that it'll run on ARM.
Sharpdevelop however requires .NET 4.0 "Full" runtime, which I couldn't find if WinRT has or not. I'm betting it doesn't, as WinRT is supposed to be a really lightweight edition of Windows.
As a sidenote, I know that Windows tablets will come in two editions, one for ARM and one for classic processors. The classic processors will run a normal Windows 8 edition, which means it can run all the native applications. Compiling C# wouldn't be an issue here - so the question is rather, can I do the same on ARM?
This would be awesome for travelling and trying out new ideas quickly.
Currently: no, and no.
It would certainly be possible to build a Windows Store app that contains an IDE and a C# compiler. However, you would not be able to run any programs built using such an app. Windows Store apps run with reduced privileges in a sandbox. In this sandbox, the CLR will only load system assemblies and assemblies contained in the app package. The app package is immutable and cannot be modified at runtime.
Actually, the .Net framework on the surface includes csc.exe, the Csharp compiler.
I've gotten code to compile, but WinRt doesn't seem to like it being run without proper signing.
The IDE won't happen for a while, not yet at least. I'm sure that with proper signing, it is possible to run a compiled executable.
Or the other guy might be right and it isn't just an issue of signing.
I've ported SharpDevelop to run on unlocked Windows RT devices, it works at least for C# Windows Forms apps. http://chentiangemalc.wordpress.com/2013/03/18/sharpdevelop-rt-edition-beta-code-windows-forms-directly-on-windows-rt/

Compiling XNA to 64-bit

I'm working on a simulator that models very complex interactions between many objects, and I mean millions.
I've used XNA because of the useful things that it lets me do easily, especially with the rendering.
My problem is that I'm running into OutOfMemoryExceptions after only a few seconds of simulation. I quickly realized that my program is only running in 32-bit mode, so I only get a few GBs of my somewhat larger amount of RAM.
How can I run an XNA game in 64-bit mode?
XNA used to be 32-bit only. You can try to compile to 64-bit, but then you are going to have issues because there won't be any 64-bit XNA libraries to load up. Everything I have found trying to back this up has been comments reminding viewers to compile as x86.
To compile as x64: Right-Click on your solution and go to Configuration Manager. From there select x64 as your Active Solution platform. You may have to create it and then select all your projects as x64. You could also try building as Any CPU since you are on 64-bit Windows, it should automatically start up in 64-bit mode.
EDIT: I found one of my old VM's that had XNA 4 installed on it. It appears that there is not a way to force it to compile to 64-bit. Even when I try to create a new platform, it will only allow me to select x86.
This does not directly answer the question. I've already upvoted TyCobb's answer.
I've run into the same issue in the past.
Have you considered switching to SlimDX? It's a wrapper around DirectX and allows you to develop .Net applications using DirectX. According to the documentation:
SlimDX sports complete support for both 32 and 64 bit targets.
It might not be as user-friendly as XNA, but I think it could be a good option for you.

.NET development for pos pc

I'm developing an application for a pos-pc running windows xp, this application is based on .NET framework 4 and use wpf for the UI.
I need to increase the performance of such application, I've read about ngen for generate native image but I don't understand very well how it works and how to use it.
Any tip, link, tutorial about ngen will be much appreciated.
I need to create a lightweight version of windows xp capable of running .NET framework 4 and use some COM object but i don't know what I can remove from the XP installer (using nLite).
I've tried Windows embedded 7 standard but the Intel gma driver are not compatible and i can't install it.
Thanks
check this one: Improving WPF applications startup time
in short, ngen is an utility that compiles the IL code generated by Visual Studio build process into machine dependent code which does not require the JIT to compile IL anymore at runtime.
How can ngen be relevant for a POS? DOnt getm e right, but this handles startup performance and POS get turned on once in the morning if at all (i.e. if they dont stay up overnight). If you ahve a WPF performacne issue may I suggest you fix those, and dont dabble with native image gneration?
Does the machine have network access? Perhaps moving business logic from the client to a service on the network would improve the performance, so that the client becomes simply a UI shell for the service.

Winform application crashs on WINDOWS 7 -64bits

I have a huge problem on one of my winform application. Someone who use my application works on windows 7 64bits and apparently it directly crashes when the application is launching.
My application works correctly on :
-Windows XP
-Windows Vista
-Windows 7 (32bits).
I developped the application on Visual C# express 2005 (.NET 2.0).
I am wondering if there is anything I can do to recompile my application to make it work on windows 7 64bits.
I am sorry, I have no access to the computer of the person (so I can't check, exception or anything like that). I am pretty sure that this issue is known that's why I'm asking you right now.
Does anyone have an idea ?
Thank you by advance for your Help
Regards,
Joze
In project properties setting window, select tab Build and change Platform target to X86. Republish..
EDIT: to the down-voter
By doing this Windows will know your program is designed for X86 use and will install it accordingly. (I've done this with Clickonce, and it works..)
Likly you use some interop x86 DLL or COM object. Try setting for your executable Target Platform x86 (not Any CPU as it is by default).
Do you use any unmanaged (com) components in your application?
If so, most likely you're including the 32bit version. If that's the case, you will have to compile 2 different versions of your program, one including the 32bit components, and the other including the 64bit components.
If that's not the case, it means you're using some platform specific code somewhere. More details about your application could help clarify the problem.

Categories