I wanted to add System.Data.Linq to my Silverlight 3.0 app, but the only references that are available to me are listed as version 2.0.50727 or lower. Shouldn't I have access to more than that?
In my project's properties, my Target Silverlight Version is set to "Silverlight 3.0" (the only option), and I'm using Visual Studio 2010 Beta 2.
Is this expected behavior, or should I be able to add that reference, and more?
You can't access System.Data.Linq in Siverlight, this dll would make no sense in the sandboxed client-side silverlight runtime. Hence no such silverlight dll exists. What you probably need to be looking into is Entity Framework on the server plus WCF to access the data from Silverlight.
For reasons best known by Microsoft all the standard Silverlight dlls have the 2.0.5.0 version numbers even the new ones added to the Silverlight 3 SDK.
This is the version number of the controls in Silverlight 3. It confused me at first. Also it's System.Linq in Silverlight and should be included by default when you create a new project.
Silverlight 4 is a separate download to VS2010.
Related
I have created a VS2013 solution that contains multiple projects. One of those projects is a portable class library targeting .NET 4.5+, Silverlight 5, Windows Store 8+ and Windows Phone 8 and this project contains a reference to an OData service in an accompanying web application.
The portable class library references Microsoft.Data.Services.Client.Portable (among others), added via nuget (WCF Data Services Client).
I have then added the portable class library to a WPF (.NET 4.5) application, a Windows Store application and a Windows Phone application and written some very basic test code to access the service. This works fine in Windows Store and Windows Phone.
The WPF application however will not compile. The errors are...
The type 'System.Data.Services.Client.DataServiceContext' is defined
in an assembly that is not referenced. You must add a reference to
assembly 'Microsoft.Data.Services.Client.Portable, Version=5.6.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
The type 'System.Data.Services.Client.DataServiceQuery`1' is defined in an
assembly that is not referenced. You must add a reference to assembly
'Microsoft.Data.Services.Client.Portable, Version=5.6.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
The thing is, I also added the WCF Data Services Client to the WPF application via nuget, but it does not add a reference to the portable library (packages\Microsoft.Data.Services.Client.5.6.0\lib\portable-net45+sl5+wp8+win8\Microsoft.Data.Services.Client.Portable.dll), instead adding a reference to the full framework 4.0 version (packages\Microsoft.Data.Services.Client.5.6.0\lib\net40\Microsoft.Data.Services.Client.dll) - which in turn is causing the error I am seeing.
Is there something I am doing wrong here or is this an error in the installation package? Note that if I delete the offending reference and add the alternative reference manually then all is well so though I have a work-around I would still like to know if I am the cause of the error.
Looking at the NuGet source code this behaviour seems to be by design.
The WCF Data Services Client contains assemblies for the following frameworks:
.NET Framework, v4.0
.NET Portable, net45, sl5, wp8, win8
Silverlight, v4.0
Installing this NuGet package into a project that targets .NET 4.5 will result in the .NET 4.0 assembly from the NuGet package being referenced. NuGet considers the more specific .NET framework to be a better match for your WPF project which targets .NET 4.5.
There is a comment in the NuGet source code about this when it looks for the best matching assembly in the NuGet package.
// Let's say a package has two framework folders: 'net40' and 'portable-net45+wp8'.
// The package is installed into a net45 project. We want to pick the 'net40' folder, even though
// the 'net45' in portable folder has a matching version with the project's framework.
Given that Silverlight uses a cut down .net framework, can I reference Unity from a Silverlight project?
There is a special version of Unity for Silverlight which you ou can donwload from here. (If you use nuget it will reference the correnct dlls for you automatically)
However Unity for Silverlight has some restrictions:
XML configuration is not supported.
Because of differences in the Silverlight security model, only public types can be created and injected by the container. The desktop version allows you to also inject internal types.
The Unity interception mechanism is not supported.
Note that (thanks the info to #Sebastian Weber) Interception is also supported since the release of EntLib Silverlight Integration Pack. See MSDN for additional information.
But you can't use the Unity "desktop dlls" in your SL project.
It exist a special version of Unity for Silverlight. You can find it here
The latest version is 2.1 and is supported for Silverlight 3-5
I am creating a Coded UI test for our system which runs on Sharepoint 2010. Part of the test sequence is creating a site; Sharepoint's UI for creating sites runs on Silverlight. Therefore, I need to create a Coded UI test for a Silverlight component which is part of out-of-the-box Sharepoint rather then part of our application. When I try to record a test, I get the following message:
No Silverlight controls where detected. Verify that the application under test is built using Silverlight assemblies with a version of 4.0 or greater and that a reference to the Microsoft.VisualStudio.TestTools.UITest.Extension.SilverlightUIAutomationHelper.dll assembly has been added to the project. For more information, see http://go.microsoft.com/fwlink/?LinkId=204562
I have two questions:
1) How can I find out the Silverlight version which Sharepoint components are built against? If they are built against Silverlight version 3.5 or earlier - I suppose the problem is unresolvable?
2) Assuming the previous question is answered - how can I make Sharepoint's Silverlight components reference the SilverlightUIAutomationHelper.dll library? That seems problematic at best to me...
Silverlight version installed on the test machine is 4; Visual Studio Feature Pack 2 is installed.
Thanks.
You can't make SharePoint's Silverlight components reference the automation helper library unless you have the source code and can recompile them. So the answer to your first question doesn't really matter.
You could modify Sharepoint XAPs to simply add Microsoft.VisualStudio.TestTools.UITest.Extension.SilverlightUIAutomationHelper.dll in there. You don't really need the code itself to reference it, it just has to part of the package. The XAP file is just a zip file so you should be able to modify this.
You will have to find where Sharepoint is getting the XAPs from and change the source (obviously you don't want to do this in prod boxes and there's even a license restriction for the Automation dll that prevents you from do it). You could also write a Fiddler AutoResponder to modify the XAP file and add the dll before it gets to the browser. For an example of this have a look at this AutoResponder:
https://bitbucket.org/mamadero/hackingsilverlightdemo/src/2fecb7b59dec/FiddlerAutoResponder
I have compiled a silverlight library that is set to Silverlight version 4 in the project properties. It consumes a dll with silverlight 4 dependencies. When I am on a system that only has silverlight 3 installed, I can reference the original silverlight library without error. At runtime I get an error about a class not existing in mscorelib. This is the behavior I would expect, except I would like to not be able to import the silverlight library at all if its not running silverlight 4. Am I missing something about how silverlight works, or should there be a way to prevent the consumption of my library before runtime on a system of an improper version?
To be fair, in Silverlight a library is a library is a library, so it assumes any missing assemblies will be supplied.
I think we may have to put this down to a "feature" of Visual Studio in that it does not exhaustively check dependencies for correct target types.
I am trying to integrate IronPython in my Silverlight application but am unable to do so. After downloading the binaries, every time I try to add the dlls as references in my VS2010 solution all I get is an error about them not being compiled for Silverlight. I have even tried downloading the source distribution, but cannot set the various projects making up the solution to build against Silverlight (the only choices I have are different versions of the .net framework).
As the IronPython website explicitly states Silverlight compatibility, why is it not working? Is there any easier way of getting scripting capabilities in my Silverlight app?
You have to use binaries from IronPython-2.6.1\Silverlight\bin folder in Silverlight.