• 0

VS Reference with exclamation mark


Question

Hello gang,

 

I found this code ( http://www.getcodesamples.com/src/5D67423E ) that returns some of the audio data so I can create visualizations with c#.  The DLL works find when included with a Windows 8 Store app, but with a desktop app (Frameworks 4.0 or 4.5) I get the yellow exclamation mark next to the Reference in the parent project.

 

Any ideas what I am doing wrong?  The MMAudioPlayer is C++, which I do no know.

Link to comment
Share on other sites

18 answers to this question

Recommended Posts

  • 0

That usually means it's not a valid CLR reference. You may need to change the platform the audio player is set to build for.

 

Eric,

 

I found this article that I believe is what you are speaking about: http://msdn.microsoft.com/en-us/library/ms185328.aspx

 

Here is my current config for this new project.  MMAudioPlayer is the component that is okay if included in a Win8 Store app, which is also defined as "x86"  Since both of these are the same I feel that I am still wrong, or not getting what you are telling me.

 

Build Configuration:  http://imgur.com/VKeQk50

Link to comment
Share on other sites

  • 0

Hmm... the config looks ok from here. I will try downloading the MMAudioPlayer later and see what I can coerce it into doing. Is it set to output CLR in the C++ config? (/clr command line option)

Link to comment
Share on other sites

  • 0

Hmm... the config looks ok from here. I will try downloading the MMAudioPlayer later and see what I can coerce it into doing. Is it set to output CLR in the C++ config? (/clr command line option)

 

Is this the command line option you are speaking about?  (again, I appologize for my lack of C++ knowledge)

 

Settings: http://imgur.com/THuICrX

Link to comment
Share on other sites

  • 0

There's a setting under the General tab for "Common Language Runtime Support" that controls it but I think you can just add the /clr to that dialog too. It should add an external reference for mscorlib.dll. It's likely already set that way if you have it working on the Windows Store side. It looks like Windows Store DLLs have different references.

Link to comment
Share on other sites

  • 0

There's a setting under the General tab for "Common Language Runtime Support" that controls it but I think you can just add the /clr to that dialog too. It should add an external reference for mscorlib.dll. It's likely already set that way if you have it working on the Windows Store side. It looks like Windows Store DLLs have different references.

 

 

Eric,

 

Thank you very much for your time and help.  I will look for the setting, but I would also like to know if there is anywhere specific in the command line where the: /clr switch should be placed?

 

Have a great evening.

Link to comment
Share on other sites

  • 0

You probably don't have matching targets for the DLL and your desktop project. You can get yellow bangs if there is a mismatch between referenced assemblies and your project. Normally it is something like .net 3.5 vs .net 4.5. In your case, I'm not exactly sure _what_ the windows Windows 8 store app target would be (but probably something different from .net 4.5). I did find this though and perhaps it will work for you:

 

http://msdn.microsoft.com/en-us/library/windows/apps/jj856306.aspx

Link to comment
Share on other sites

  • 0

It can go anywhere under Command Line I believe but you can also turn it on in the General tab by changing that setting.

post-175510-0-62737000-1386683456.png

Is there any way to download the zip of that project? It tells me it hasn't been published.

EDIT: I downloaded the source files individually and dumped them into a CLR class library project and it fails to compile miserably for me.

I don't know very much at all about C++ CLR or DirectX myself. :(

Link to comment
Share on other sites

  • 0

It can go anywhere under Command Line I believe but you can also turn it on in the General tab by changing that setting.

attachicon.gifScreenshot (8).png

Is there any way to download the zip of that project? It tells me it hasn't been published.

EDIT: I downloaded the source files individually and dumped them into a CLR class library project and it fails to compile miserably for me.

I don't know very much at all about C++ CLR or DirectX myself. :(

 

No worries Eric, neither do I.   I am unable to add anything to the command line,,, don't know why.  Nor does the "Common Language Runtime Support" option exist for me.  I am using VS 2013, and I see you have 2013.  So that could be the issue.

Link to comment
Share on other sites

  • 0

Have you looked at NAudio? I don't think it supports Windows Store projects but you could always abstract your audio into interfaces and use different engines for desktop/Metro.

 

I did take a brief look at NAudio, but had to use the MMAudio because it worked for Win Store.... ah, the joy of various components based on platform.  I may have to look back at NAudio, thanks for the reminder

Link to comment
Share on other sites

  • 0

So, I tried the MMAudioPlayer library out myself to see what exactly was going on (including installing VS2013; creating a Windows Runtime Component Library; incorporating in the MMAudioPlayer sources). It turns out that the library code for MMAudioPlayer is Windows Runtime (WINRT) platform code (http://en.wikipedia.org/wiki/C%2B%2B/CX ; http://en.wikipedia.org/wiki/Windows_Runtime). This means that it is compiled as an unmanaged DLL; whereas, your desktop c# app is .net or common language runtime (CLR) code. The two can't inter-operate under normal circumstances. At the very least you'd have to jump through hoops to do it.

 

I played around with the options try to make MMaudioPlayer compiled as an CLR dll, however, it doesn't work because some of the used components used by MMAudioPlayer are only available via the native C++:

Error 2 error C1189: #error :  ERROR: Concurrency Runtime is not supported when compiling /clr. C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\concrt.h 26 1 MMAudioPlayer
Moreover, it looks like when you developing Windows Store apps, it uses something called XAML (http://en.wikipedia.org/wiki/Windows_Runtime_XAML_Framework). I'm not sure how it work internally, but that layer let's you use c# code in non-desktop apps.

 

 

See the last post here (don't bother with the tlbimp.exe, it doesn't work):

http://stackoverflow.com/questions/14028713/could-not-add-reference-to-winrt-c-dll-project

Link to comment
Share on other sites

  • 0

It looks to me that you can somehow use XAML with WPF C# projects --> so I assume that's how you can use C++/Cx DLLs with C# in desktop applications.

Link to comment
Share on other sites

  • 0

The MMAudioPlayer source isn't unmanaged, it's essentially an interop library that lets you access DirectX's XAudio2 in managed code. Windows Store projects have an option to create something similar to a library called a runtime component. The project appears to be unmanaged but it's not. It has a manifest file that specifies how other projects can consume it.

XAML is an XML subset that you use to create user interface elements. It doesn't have anything to do with C++ or DLLs. It's common to WPF, Silverlight and Metro.

Link to comment
Share on other sites

  • 0

The MMAudioPlayer source isn't unmanaged, it's essentially an interop library that lets you access DirectX's XAudio2 in managed code. Windows Store projects have an option to create something similar to a library called a runtime component. The project appears to be unmanaged but it's not. It has a manifest file that specifies how other projects can consume it.

XAML is an XML subset that you use to create user interface elements. It doesn't have anything to do with C++ or DLLs. It's common to WPF, Silverlight and Metro.

 

All C++/Cx code by definition is unmanaged. It's literally native C++ code with extensions (did you read the links I sent?). If it weren't, it would be compiled into CLR byte code and it is not. You can verify this by running it through an x86 disassembler* as well as attempting to run it through CLR bytecode disassembler**. The former will work, the latter will fail. With Windows Runtime Component projects you use the /Zx switch in VS so that that you can generate metadata files that operate essentially as a managed interfaces/ABIs for WINRT projects to use (e.g. store apps). These interfaces actually are managed code, or rather, in almost the same format as what you would see in CLR bytecode (e.g. so they a readable by a CLR disassembler).

 

Here's the problem, a Windows Runtime Component project's generated metadata interface file is not readable by a regular winforms or CLI C# project even though the interfaces are almost the same. Moreover, you can't reference the DLL directly because it is all native code. So you are SOL from what I can see. I don't believe there is a way around this. And I'm sure MS has some sound technical reasons for this (or just deprecation or simply no good reason at all).

 

Finally, let me clarify exactly what I was talking about w.r.t. XAML. Windows 8 has an newer XAML layer called Jupiter which allows WPF applications to interface with WINRT code. Ergo, you can create an XAML WPF C# project and then _use_ or _reference_ Runtime Component Library Project DLLs. This is how XAML is related to the DLL issue...

 

Don't believe me about the managed/unmanaged code? Here's a VS2013 C++ Windows Runtime Component project to build MMAudioPlayer (it also has pre-built DLLs) so you can fire up a disassembler and check for yourself:

https://www.dropbox.com/sh/amjbnnnkmhz1u3i/l3syTkacc3

 

* objdump, ollydbg, idapro

** ILSpy, .net reflector

Link to comment
Share on other sites

  • 0

 And I'm sure MS has some sound technical reasons for this (or just deprecation or simply no good reason at all).

DEPRECATE ALL THE THINGS seems to be the motto at Microsoft these days. Especially with everything .NET. Heck I heard Windows 8.1 deprecated a lot of Windows 8 APIs already!

  • Like 1
Link to comment
Share on other sites

  • 0

DEPRECATE ALL THE THINGS seems to be the motto at Microsoft these days. Especially with everything .NET. Heck I heard Windows 8.1 deprecated a lot of Windows 8 APIs already!

 

When will they deprecate 32-bit executables ;-)

Link to comment
Share on other sites

This topic is now closed to further replies.