Where I can find Microsoft.DirectX assembly to reference - c#

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

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.

Microsoft DirectX Sound on Visual Studio 2017

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.

Using System.Drawing package from multiple machines (multiple OS)

We are building a .Net Core 2.0 C# web app that uses System.Drawing package.
I am writing code on Mac, but it will be also developed on the Windows machine, and deployed into Linux server.
To use System.Drawing on OSX I had to add runtime.osx.10.10-x64.CoreCompat.System.Drawing Nuget package to my project dependencies.
But that code now doesn't work on the Window machine.
We get the System.AccessViolationException when trying to use DrawString method of Graphics (part of System.Drawing) object.
So, my question is what is common way to solve this?
Is it even possible to use System.Drawing classes in this multi-os setup?
The same System.Drawing code should work on Linux, Windows and macOS without any changes. You're correct that you need to either manually install libgdiplus (e.g. via brew install mono-libgdiplus) or reference runtime.osx.10.10-x64.CoreCompat.System.Drawing for System.Drawing to work on a Mac.
System.Drawing will work on Windows without any external dependencies.
If you're still using CoreCompat.System.Drawing (which I maintain), I'd recommend you migrate to System.Drawing.Common instead - this the is Microsoft implementation of System.Drawing for .NET Core.
If the issue then still reproduces on Windows, your best bet would be copy a should piece of code which can be used to reproduce your issue, so I can have a look at it.

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.

MonoMac Could Not Load Assembly or Dependency

I have a fairly simple application that I built using MonoDevelop 3.0/XCode 4.0/.NET 4.0 on OS X 10.7 (Lion). Basically, I have a Windows GUI and a Mac GUI for the application, and both share a class library. The class library is very simple (deliberately), and passes the MoMA tests with flying colors. My OS X GUI runs perfectly on my development OS X machine, but when I create a .pkg file and install it on a test OS X machine, it won't run at all. I have the Mono runtime installed on the test machine -- the runtime only, not the SDK or MonoDevelop. The application will open, but as soon as I make a call into the shared library, it fails with
System.IO.FileNotFoundException: Could not load file or assembly 'xxx' or one of its dependencies.
My shared library only has the following dependencies:
System
System.Configuration
System.Core
System.Xml.Linq
System.Data.DataSetExtensions
Microsoft.CSharp
System.Data
System.Xml
Surely the basic Mono framework supports all of these assemblies, right? What am I missing? I can't believe that releasing a simple application like this (via .pkg file, not AppStore) is so difficult! Could someone please point me in the right direction? Thanks.
OK, so, total noob/forehead slapping moment: the reason my application ran on my development OS X environment but not on the test box? .NET framework! I built the class library with Visual Studio 2012/.NET 4.5/Windows 7, checked it with MoMA, then copied it to my dev OS X, set a reference to it in my MonoMac project, and everything was fine, right? That's because that box had MonoDevelop and the .NET framework on it! When I created my .pkg and installed it on a new OS X box, the install was smart enough to download and install the Mono environment, but not the .NET framework, and who can blame it? The solution: build the class library against Mono 4.0, and use that assembly in my MonoMac release! Problem solved.
Thanks for help and comments. Please forgive the basic stupidity of this question: I'm not only a Mono/OS X noob, I'm a desktop development noob, too. I'm a web guy, for cryin' out loud!

Categories