How do I reference System.Windows 5.0.5 assembly (Silverlight) from .NET 4.5 library project? - visual-studio

I have a project written for Silverlight 5, which references Silverlight's System.Windows assembly in version 5.0.5.
Now I want to create a unit test project for it using a usual .NET 4.5 library project. When I try to add a reference to the System.Windows assembly 5.0.5 from Silverlight (using the browse dialog), Visual Studio adds the version from .NET 4.5.
Hence the version number does not match.
Why does Visual Studio behave this way?
How do I fix this?

You can reference Silverlight assemblies from a .Net project, but once you have managed to add one, you will likely have problems with dependencies on other libraries.
It will be easier on you if you to try a different approach...
I would suggest using the Silverlight Unit Test Framework to deal with testing your Silverlight code.
If that doesn't fit your need, perhaps Portable Class Libraries will.

Related

Could not add nuget package to class library

I am using Visual Studio 2017, I created an empty .NET Core Class Library, I tried to add a package to my project and got the following error
Invalid portable frameworks for '.NETPortable,Version=v0.0'. A portable framework must have at least one framework in the profile
I searched internet for help, could not find anything. This class library is referenced in a ASP.NET MVC Core app which does not have a project.json file, I guess it is gone now. Any help is appreciated.
I suppose you have created a nuget package that you want to use in your projects. Mentioned nuget package is created as Portable Class Library and can be installed in regular Class Library projects.
If you want to be able to install this package to .NET Core class libraries or console apps (which includes web applications) you need to create it as .NET Standard Class Library. There is a walk through on how to do it: Create .NET standard packages with Visual Studio 2017.
UPDATE:
From what I have found C++ is not supported in .NET Core and there is no plans to support it right now Proposal: C++/CX support, Will CoreCLR support C++/CLI crossplat?, Using .Net (C++/CLI) legacy code in Net Core.
I am not an expert in C++, but maybe it is possible to create a library in C++ and P/Invoke it with C# and wrap both in NuGet package? Or rewrite it completely in C#?

Is TPL DataFlow included with either .NET 4.5 or .NET 4.5.1?

I'm confused. We upgraded our project recently to .NET 4.5.1. We installed .NET 4.5.1 on our servers.
I'm referencing assembly System.Threading.Tasks.Dataflow from the GAC at C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Threading.Tasks.Dataflow\v4.0_4.5.9.0__b03f5f7f11d50a3a\System.Threading.Tasks.Dataflow.dll
CopyLocal is set to false as (I assume) it's part of the Framework, so should be already installed wherever the app is deployed.
The trouble is, when running on the server, it says it can't find this assembly.
I've read here that is is part of .NET Framework 4.5:
but the library is now built-in with .NET 4.5.
...and I've read here that it isn't!
The TPL Dataflow Library (System.Threading.Tasks.Dataflow namespace) is not distributed with the .NET Framework 4.5
What gives? It doesn't look like it is. Is it just part of the 'targetting pack'? Is it me, or are these in-place upgrades more agro than they're worth?!
I'm not sure why that page says it is part of .NET 4.5 -- it's still an out-of-band NuGet release, like Entity Framework, MVC, etc.
I recognize this question is pretty old, but I wanted to add my solution as well. I found adding the below two items to the Visual Studio 2019 install (run Visual Studio Installer > Modify > .Net Desktop Development) the problem went away and it was able to pull System.Threading.Tasks.Dataflow from the GAC.
Edit: Installing Visual Studio 2015 also seemed to be required. Obviously it isn't VS 2015 itself, just something it comes with. But there are too many packages for me to figure out which one easily.
Edit2: This isn't really the best solution, more of a stopgap. MS suggests downloading it through Nuget. https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.dataflow?view=netcore-3.1
The TPL Dataflow Library (the System.Threading.Tasks.Dataflow namespace) is not distributed with .NET. To install the System.Threading.Tasks.Dataflow namespace in Visual Studio, open your project, choose Manage NuGet Packages from the Project menu...

Visual Studio 2010 1 Class Library Project Compile 2 DLLs (.NET 3.5 and .NET 4.0)

I have a Visual Studio 2010 Solution with a class library project. What I want to do is compile 2 DLLs on build. I want to compile against .NET 3.5 and .NET 4.0 respectively. Something like below.
myproject\bin\debug\3.5\assembly.dll
myproject\bin\debug\4.0\assembly.dll
Is this possible?
Maybe you'can write a simple problem to execute on each build, it simply does:
make a copy of your working project file (*.csproj, *.vbproj, etc.)
edit the target info from 4.0 to 3.5 (or from 3.5 to 4.0) and update other related properties, it should be simple enough.
call msbuild.
I've used this approach before for different purpose.
The target framework is part of the application project settings that cannot depend on the configuration (unlike build settings).
I'm afraid you will have to create a separate project for each framework version.

IronRuby references conflict with System.Linq?

Using Visual Studio 2010, when I add the four IronRuby references to an existing project that uses Linq in several methods, the project won't compile due to not being able to find System.Linq all of a sudden. Does the IronRuby/.Net 4.0 Framework change the location of Linq or am I missing something?
Thanks,
Becky
Are you using the build for .NET 4.0?
The 3.0 build does have those overrides but they should be included in .NET 4.0.
http://ironruby.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=33305

VS2008 to VS2010 project conversion

I have a component project build in VS2008 and targeting the .NET Framework 3.5. I recently downloaded the VS2010 Beta 1 to make sure this project would convert over correctly when the time comes to switch to the new IDE. This project contains references to a couple of 3rd party dlls built against version 2.0 of the framework. I changed my project to build against the 4.0 version of the framework but when I try to build the project I get a ton of errors that looks like the compiler can't recognize the class types of those 3rd party libraries similar to what is below.
"The type or namespace name 'Data' does not exist in the namespace 'Microsoft.Practices.EnterpriseLibrary' (are you missing an assembly reference?)"
I'm trying to figure out why I can't compile. From what I have read .NET 4.0 uses a different version of the CLR. How or why would that impact my ability to have access to those types? Am I going to have to
a) Get the source code and recompile in VS2010 / .NET 4.0 and then reference that assembly or
b) Wait for project authors to do "a" above and release their assemblies targeting the 4.0 CLR? or
c) Something else because perhaps my VS2010 install is borked?
I can change the project properties to target 3.5 and everything works as I expect under the 2010 IDE.
I suspect this is because .NET 4.0 uses CLR 4.0, not 2.0. EL 4.1 will have been built against CLR 2.0, so I'm not sure I'd expect it to be found without help.
Seems like a CLR versioning issue to me.
For the current time, I will recommend b) and/or just compile to v2.0/v3.5.
Any specific feature that you want to use in v4.0?
I wanted to mark this question as answered and based on the comments and my own experiences, I think that Mehrdad is correct in the comment attached to the question and that it was a VS2010 project conversion problem.

Resources