I need to use the BitmapImage class which is part of the System.Windows.Media.Imaging namespace.
From Visual Studio 2012 Express, I started with a WPF desktop application project template, and I can see the relevant dll, PresentationCore.dll is present under the references.
This link on MSDN indicates this reference should be sufficient. This thread indicates the same, and highlights the fact that the necessary dll is referenced by default when using a typical wpf project template in VS2012.
And yet, in my C# code behind, the compiler complains on my using System.Windows.Media.Imaging; statement that Media cannot be found.
This problem seems to not be uncommon, and yet I found no solution to it.
UPDATE:
When looking at the properties for the reference to PresentationCore.dll, I see that version is 4.0.0.0 and runtime version is 4.0.30319. I am making a cheap relation to the fact that BitmapImage exists only for .net 4.5 supposedly... Could this be a hint to the problem ?
There are 3 required references need for a WPF project, PresentationCore, PresentationFramework and WindowsBase. See WPF Architecture and WPF Architecture - and overview ... . The second one has a nice description of the contents of the libraries.
Related
I have a asp.net MVC 4 Application I'm working using visual Studio 2010.
I have added 3 Class libraries to the solution and for some reason only one of them is being picked up by visual studio.
So in any class where I reference the other in Using statement. I get the following error "The type or namespace name "*" does not exist in the namespace "MyProject"(are you missing an assembly reference?)"
I have right clicked on the main project, selected properties and checked that all the class libraries are listed under projects, which they are.
I have right clicked on the solution, selected properties and ProjectDependcies, and this is also set up correctly.
The class libraries are all listed in the References folder for the main Project.
I've tried cleaning and rebuilding , no joy any suggestions ??? Thanks
The DLLs are likely built using an later version of the framework than your project is targeting.
The version of .NET that your class libraries are targetting is greater than the version your application is targeting.
Either demote your libraries to use the version of .net targeted by your application, or promote your application to the version used by your libraries.
I have recently acquired the student licence of Mono Android from Xamarin.
After making a simple project, i decided to start using some DLL's i am familiar with such as Json.Net and H.A.P on my Android Application (mono project), and that's when the problems started.
After trying to pull those references from NuGet, they failed since the "Android Application" project is not known leading to no .dll installed (NuGet tries to match the project type with the correct .dll to be downloaded be it WindowsPhone, .NET4, .NET 3.5 and so on).
So i moved on to mannually referencing the libraries, since i have them downloaded on my PC. Referencing Works, but as soon as i try to access the HtmlAgilityPack it raises an exception.
Error CS0012:
The type 'System.Xml.XPath.IXPathNavigable' is defined in an assembly that is not referenced.
You must add a reference to assembly 'System.Xml, Version=x.x.x.x, Culture=neutral
The exception is raised on the first execution of the code because of J.I.T compilation of .NET, i know this.
Question:
How can i use my "so loved" .dlls on my Mono Android Project?
Do i need the source code of those libraries in order to use them on my projects?
Thanks in Advance
In order to recompile an assembly you will need the source.
To see what assemblies are provided by Xamarin.Android and Xamarin.iOS you can visit these two pages:
http://docs.xamarin.com/guides/android/advanced_topics/assemblies
http://docs.xamarin.com/guides/ios/advanced_topics/assemblies
One way to recompile it would be to make a Android Class Library or iPhone Class Library and add a link to all the files in the original source and then compile it. Or when Xamarin have their PCL support done, do something similar just in a PCL so that you have one DLL targeting multiple platforms.
You may also find this post useful, which briefly describes how to compile HtmlAgilityPack against Xamarin.Android: http://forums.xamarin.com/discussion/comment/2139/#Comment_2139 You might need to alter some things as this is from December 2012, since then things might have changed.
In Visual Studio 2012 in a blank new Class Library I am trying to add reference to an existing project in the solution, also a Class Library, MonoGame.Framework.Windows8 (https://github.com/mono/MonoGame), but get the error:
Unable to add reference to Project MonoGame.Framework.Windows8
I have built the existing library, MonoGame, successfully and made it a dependency of the new one. What could be the problem?
(It's extremely annoying the error message does not give a reason!)
Trying to add the built dll has a reference gave a more explicit error message which has solved the problem for me, it said:
“A reference to ‘x’ could not be added. The project targets ‘.NetFramework’ while the file reference targets ‘.NetCore’. This is not a supported scenario”
The MonoGame Class Library is a Class Library (Windows Store apps) type! (The bit in parenthesis is important! Presumably the difference is the Windows Store apps type use .Net Core which is not the same as .Net Framework).
So to get it working your project must be a Class Library (Windows Store apps) which is available under the Windows Store option in Add New Project.
I suspect the problem is to do with the 'Target Framework' in project options.
I don't know how MonoGame works for Windows 8 but when you're developing for Android the target framework options are the different versions of Android [e.g. Android 2.2 (Froyo)]. When you create a regular class library you have choices between the different versions of the .NET framework or Mono [e.g. Mono / .NET 4.0].
Unfortunately, these frameworks are not compatible with each other. You can't add a project reference for Android to a .NET framework class library and visa-versa.
The solution is to use a Portable Class Library. They are specifically designed to deal with this issue. The downside is that you will only have access to the subset of assemblies provided in the lowest denominator you choose to target.
You might also want to consider code sharing between projects using linked files. It can make maintenance a little trickier but gives you a little more control over code that should compile in both target frameworks but doesn't fit into the portable class library. Here's a related question:
Project reference vs. file links in Mono multi-target projects
The key to all of this once you understand what's going on here is how you structure your solution. With a little care you can have nearly all your code shared across different platforms.
I might be because of both projects are using different Framework versions and change the Framework versions in both Projects of properties section then your problem might solve.
Same question I guess here:
Visual Studio 11 metro apps unable to add reference?
The answer was:
What are you adding a reference to? Metro style apps can only add references to other Metro style class libraries or portable class libraries
I found this problem on my C# project which I started at Visual Studio 2010, when I go to another PC I use in 2008, I open the project.csproj:
A get or set accessor expected
and warning:
The referenced component 'Microsoft.CSharp' could not be found.
I thought that it was about .NET Framework or Microsoft.CSharp is not located, because it says that:
Could not resolve this reference. Could not locate the assembly "Microsoft.CSharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors
but I'm not sure about the problem, can you guys give me a solution? Really appreciated.
It sounds like you are targeting .NET 4.0 in the project, and then trying to load it in VS2008 which only targets up to .NET 3.5.
If you need to use the project in VS2008, then you should re-target the project at .NET 3.5:
and then remove any incorrect references (they'll probably have yellow warning triangles on them anyway).
The A get or set accessor expected also suggests you're using new C# syntax, for example dynamic. If you need to target older C# compilers, you'll have to not do that. If you are using multiple IDE versions and it is being a problem, then to ensure you don't do that accidentally you can set the language version for the project via Project Properties -> Build -> Advanced:
I am trying to compile AvalonEdit for Silverlight, but I am not sure how to do it as I never worked with Silverlight, only WPF.
I tried to add this control to my Silverlight application but Visual Studio complained that the assembly wasn't compiled against Silverlight.
I thought it was gonna be a matter of picking Silverlight under the target platform in the project settings.
Any ideas?
Silverlight and WPF assemblies are not compatible. So any assembly you reference from your Silverlight assembly must also have been compiled as a Silverlight assembly. I'm assuming your reference to "project settings" is your assembly, not the third party assembly.
But, compiling WPF code as Silverlight may be challenging. Silverlight is a functional subset of WPF so the code may use features not available in Silverlight.
You need to create new project which targets silverlight (File - New Project - Silverlight) and then add all the source code from the AvalonEdit source code into that library.
Edit:
Also note that the control might use classes that are not available in Silverlight. From the codeplex discussion related to this control (from year 2009):
Silverlight does not have the System.Windows.Media.TextFormatting namespace, so you'd have to rewrite a large part of the ICSharpCode.AvalonEdit.Rendering namespace if you want to port AvalonEdit to Silverlight.
In silverlight projects you can't reference non-silverlight dll's or projects. So in this project if there is an essential non-silverlight dll for building this project. You cant do this build.
If there are just some usages wfp supports but silverlight doesnt support find out this differs.
Then exclude these codes or use pragma
#if !WPF
//Todo
#endif