Microsoft DirectX Sound on Visual Studio 2017 - c#

I have an old program made with Visual C# 2010. Now I would to use it again so I tried to compile on Visual 2017 Community but it launch an Exception on MicrosoftDirectSound. I understood that it's because is on 32bit so I would ask you if there is any workaround to implement that directx or alternatively what I have to use in the new scenario. I tried with "corflags" too, but it returns a warning about strong named signed.
System.BadImageFormatException: ... is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

Microsoft.DirectX.DirectSound is part of the legacy Managed DirectX 1.1 assemblies. They only supported for the .NET 1.1 and .NET 2.0 Runtimes and not the modern .NET 4.x Runtime. You also as you note have to force the use of /platform:x86.
Your best option is to use SlimDX which is intended as a drop-in replacement for the Managed DirectX 1.1 assemblies including x64 support. A more modern solution is SharpDX, but of course you probably shouldn't be using DirectSound in a new app anyhow.
See DirectX and .NET
The other thing to keep in mind is that the legacy DirectX Managed DirectX 1.1 assemblies are only installed by the legacy DirectX SDK or the deprecated DirectX End-User Runtime Redistribution Package on systems with the .NET 2.0/3.x Runtime enabled. See Not So DirectSetup and DXSETUP Update.

Related

DirectX assembly reference on Windows 10 and Visual Studio 2013

Running my legacy C# application in Windows 10 on Visual Studio 2013 is proving to be a nightmare. The application has an assembly reference to DirectX. Previously, you could just download DirectX SDK and that was 500 MB. Now, you need to download the entire Windows SDK, which is a whopping 4 GB - as they have bundled DirectX together with the Windows SDK. I am lost - the wifi is poor and its taking ages. Any other ideas what i could do? Is DirectX SDK for Windows 10 available separately?
You are referring to the legacy Managed DirectX 1.1 assemblies. They are not in the Windows 10 SDK. They are only deployed by the legacy DirectX SDK and the legacy DirectX Setup package.
See Where is the DirectX SDK? and this blog post.
The legacy DirectX Setup and DirectX SDK will not install the Managed DX 1.1 assemblies unless the system has a .NET 2.0 compatible Runtime (3.5 or 3.0 works as well) installed. It is not supported by .NET 4.0 or later which is what is included with Windows 10 OS.
See DXSETUP and Not So Direct Setup.
Once they are installed, you'll also run into the problem that they don't work with .NET 4.0 which is what VS 2013 is expecting you to use. There are apparently some hacks out there you can try, but MDX was designed for .NET 1.1 originally.
You should move to something more modern like SharpDX or SlimDX. SlimDX was intended as a replacement for the Managed DX 1.1 assemblies so it's probably the easiest to move to, but the project itself is no longer active.

Where I can find Microsoft.DirectX assembly to reference

I am wondering where I can find Microsoft.DirectX assembly to reference?
It seems like MS Windows 7 has DirectX installed but I cannot find this assembly using Reference Manager Window of Visual Studio 2015.
Any clue what should be installed?
Microsoft.DirectX is the deprecated Managed DirectX 1.1 assemblies that date back to the early 2000s. They are deployed by DXSETUP from the legacy DirectX SDK. They are also not compatible with .NET 4.0, and only support Direct3D 9. In other words, they are ancient and don't use it.
Instead you should use SlimDX or SharpDX.
See DirectX and .NET

Visual Studio 2010, C# and directx managed code

I am trying to use DirectX managed code for Visual Studio 2010 with C#.
I added the references from DirectX from the following path C:\WINDOWS\Microsoft.NET\DirectX for Managed Code\1.0.2902.0
Now every time I try to run a program I will get a Delay Notification saying that "Microsoft Visual C# 2010 is waiting for an operation to complete...", and the program is frozen forever.
I need to close it from task manager.
I need help to solve this problem.
The legacy DirectX Managed Assemblies 1.1 are only compatible with .NET 1.1. and the .NET 2.0 runtime (i.e. 2.0, 3.0, and 3.5). They do not work with the .NET 4.x Framework which is what VS 2010 uses by default.
If you are looking to port existing Managed DirectX 1.1 assembly code, see SlimDX.
For a new app SharpDX is an excellent choice and is supported on a newer 'modern' Microsoft platforms.
See this blog post.

C# windows application using Ubuntu

I am interested in C# windows application development. But now that I have shifted to Ubuntu I am no longer able to do it. Is there a way other than virtual box to develop a C# windows application in ubuntu??
Well there's the Mono Project but if you want the Microsoft .NET implementation you need Windows.
You might be interested in Mono Project.
It is an open source, cross-platform, implementation of C# and the CLR that is binary compatible with Microsoft.NET. However Mono is not totally up-to-date with lates releases of .NET Framework. It is a mix of .NET 2.0 - .NET 4.0 features.
The Mono project focuses on compilers and runtime libraries and does not directly provide an IDE like Visual Studio. Check here to check available solutions.

Deploying c# app - user need to install .net framework?

Hey guys - I just wrote an app using c# and ready to deploy it. Never deployed a c# app before.
I deployed it and VC# outputted a .application file, application folder, and an installer. One of my users ran the installer (Windows 7) and was prompted to download/install the .net framework - which took upwards of 10 minutes. This is not acceptable for how simple my app is.
Moreover, I will need this app to be able to run on mac osx and linux if possible. Should I have wrote this in Java instead (poor planning on my part). What are my options?
C# is compiled to bytecode that runs on the CLR, the virtual machine that's at the core of the .NET framework. So yes, you need the .NET framework to run that.
Most current versions of Windows (XP, Vista, 7, etc.) come with some version of the .NET framework pre-installed, so your users don't have to download and install it. However, you might have used a version that's not already installed on the computers of (some of) your users.
For Linux and Mac OS X there is Mono, which is an open source implementation of .NET, but it does not contain everything that Microsoft's .NET contains, so your program might not work fully on Mono.
Using Java is not a real solution in the sense that your users would need to download and install the JRE (Java Runtime Environment) to run Java programs, very similar to the .NET framework. An advantage if you'd have used Java, is that Java is much more cross-platform compatible than .NET (Microsoft has no real interest in making .NET run on anything else than Windows).
.NET apps require the .NET framework. Java apps require the JRE. Your app is simple because .NET has done a lot of the work for you. A lot of companies write desktop apps in C++, but you will have to be mindful of cross-platform issues.
Yes, with any language that compiles to run on a managed runtime (.NET or Mono CLR, Java JVM) you will need to have that runtime installed. A C# application can compile to run on Windows on the .NET CLR, or on all the platforms you mention to run on the Mono runtime instead. Alternatively, a Java application would compile to run on the Java JRE, which is also compatible with all the platforms you mention.
So with either language there is potentially this extra installation overhead, and with either language you can achieve what you want.
You'll need to have .NET installed on your client's system in order to use your application.
As for running cross-platform - depending on how your Application is written, this can be simple or difficult.
You may want to look at Silverlight. This is directly supported on OS X and works on Linux via Moonlight.
Another alternative is to use Mono to run your .NET application on other platforms.
A C# app will need an implementation of the CLR (.NET) running on the local machine in order to run. A Java app will need an implementation of the JVM so it is really no different. On Windows, I would expect most people to have a .NET install.
Take a look at the Mono project as far as running it on Linux and Mac:
http://mono-project.com/Main_Page
One thing you can consider is using an older version of the .NET framework to ensure that the greatest number of people have it installed. I would use .NET 3.5 or even 2.0 if you do not need fancy new features. That would have been installed already on Windows 7 for example.
Since the Windows 7 user had to download the framework I assume you are currently targeting .NET 4 which means you must be using Visual Studio 2010 (or an express version). Here is a link that tells you how to target a different version of the framework:
http://msdn.microsoft.com/en-us/library/bb398202.aspx
One quick note about Mono, it is an excellent cross-platform option but it does not support the Windows Presentation Foundation (WPF) GUI framework at this point. You will either have to use Windows Forms or create different front-ends for different platforms.
If you want to create a Linux GUI (also available on Windows and Mac) you can try GTK#:
http://www.mono-project.com/GtkSharp
For a Mac native GUI you can check out MonoMac:
http://mjhutchinson.com/journal/2010/06/09/monomac_in_monodevelop
An excellent IDE for cross-platform .NET development is MonoDevelop (it will read your VC# project files):
http://monodevelop.com/
Like Java, .Net languages need a runtime installed. The full .Net framework is sometimes too big for small applications, so there is a smaller version of it call the compact framework with a smaller footprint that will install and download faster. You can read about it at http://msdn.microsoft.com/en-us/netframework/aa497273.aspx. As noted by other answers most current versions of Windows come with various versions of .Net framework, so this installation may not be needed for every user.
As far as your cross platform needs go Mono allows for running .Net applications on Linux, I am not sure about running them on OSX. My assumption is you can not. Unfortunately your cross platform requirements made .Net a bad choice, and you should have gone with Java.
Other people gave you complicated answers. Well here's my simple answer. .NET framework is needed to run .NET applications and so do Java need JVM (as MCain said). Starting with Windows Vista, Microsoft includes .NET Framework built inside Windows. And in addition, .NET have versions, from 1.0 to 4.0. With Vista and Windows 7, .NET 3.5 is installed by default. I think your app is targeted for .NET 4.0 which is why a Windows 7 user needed to install .NET framework. For me, if I have to write a simple program, I'll use .NET 2.0 (later version = larger libraries, etc) so that my users (if they are Vista or Windows 7) don't have to install .NET again to run my software. You can choose which version of .NET you will target from New Project Window in Visual Studio.
You can change the target framework in the properties tab. If you start a project in VS2008 the default is .net 3.5 and for VS2010 it is .net 4.0. If you don't need the advanced features you can change your target back to 2.0 which should be available on most computers by now (I would guess far over 90%). Be sure to remove dependencies which are not available in 2.0 (like System.Linq, System.DataSet.Extensions) and the accociated imports (But the compiler will tell you what to do).

Categories