Using JSON.Net from Silverlight 3 in VS2010

Dec 17, 2009 at 3:12 PM

I'm building a Silverlight 3.0 app on VS2010. I can reference the .DLL from the Json35r5\Bin\Silverlight folder but I get the following error when building the project. The article says to include <loadFromRemoteSources enabled="true"/> in the configuration file but what app.config would that be? I want the json.silverlight.dll to be included in the XAP for the project.

Thanks.

Error 23 The "ValidateXaml" task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Users\steveres\Documents\Visual Studio 2010\Projects\TestSLPlusAuth\BingWrapper\Bin\Debug\Newtonsoft.Json.Silverlight.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
File name: 'file:///C:\Users\steveres\Documents\Visual Studio 2010\Projects\TestSLPlusAuth\BingWrapper\Bin\Debug\Newtonsoft.Json.Silverlight.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute()
   at Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute()
   at Microsoft.Silverlight.Build.Tasks.ValidateXaml.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)

 BingWrapper

Coordinator
Dec 17, 2009 at 7:56 PM

http://www.google.com/search?q=loadFromRemoteSources+silverlight

?

Apr 9, 2010 at 6:56 AM

Make a note of the DLLs listed in the error message. Open the folder(s) containing each of these dlls in Windows explorer, right click, properties and choose to "unlock". Basically Windows is treating the referenced assemblies as unsecure (since they were downloaded from internet) and hence restricting access. You can unlock them.