WCF RIA services and System.ServiceModel.DomainServices.Hosting - silverlight

I am developing my first project using WCF RIA services. I was able to build a small application and ran it successfuly on localhost. When tried to upload on a server, I got the following error when browsing it :
"Could not load file or assembly
'System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified"
I looked for this reference on my project and did not find it. I tried to add it from C:\Program Files (x86)\Microsoft SDKs\RIA Services\v1.0\Libraries\Server, but Visual Studio warns me:
You cant add a reference to
System.ServiceModel.DomainServices.Hosting.dll as it was not built
against the silverlight runtime.silverlight projects will only work
with silverlight assemblies
What should I do?
Thanks

Found the problem: on my .Web under references, found the needed dll.On properties, changed copy local to True

Related

Microsoft.Bcl.AsyncInterfaces error (in CSVHelper method) when running the application installed by Visual Studio Setup project

I have a WPF application that reads a CSV file using CSVHelper which I installed using NuGet. Here's the project, system, etc version info.
Microsoft Windows 7 Professional Version 6.1.7601 Service Pack 1 Build
7601
Microsoft Visual Studio Community 2019 Version 16.4.5
NuGet Package Manager 5.4.0
WPF Project Target Framework: .NET Framework 4.7.2
CSVHelper Version: 15.0.5
CSV reader method is straightforward; read a file and put it in a list. Nothing fancy. I'll link the entire project at the bottom so you can download and try it out if you want.
When I run the executable made in either Release or Debug builds, they work fine. They read the file, put contents in a list, and display on a DataGrid just fine. As a next step, I created a standard Visual Studio Setup project, and created an msi installer, which I used to install the app in my PC.
When I run that executable (which is in my Program Files directory), however, the application throws an exception. Here's the exception message and Stack Trace.
Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
at ReadCSVTest.MainWindow.ReadPeopleList(String path, List`1& people, String& msg)
at ReadCSVTest.MainWindow..ctor()
Since the error says couldn't load the assembly Microsoft.Bcl.AsyncInterfaces, I added that from NuGet and ran everything again, and I still get the error. What's the problem here? What does it mean that Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context.? And why do I only get this exception when I run the executable installed by the Setup project?
Please download the entire project from HERE.
Just so anyone runs into the same issue in the future; as Jones suggested in the comments, downgrading each of the two libraries to following versions fixed the issue for me.
CsvHelper ==> 12.3.2
And
Microsoft.Bcl.AsyncInterfaces ==> 1.0.0

VS2017 15.4 Preview "Windows Application Packaging Project" tool failed to generate a working app

I added the new "Windows Application Packaging Project" that comes with vs2017 15.4 preview.
When adding my project to the "Applications" and debugging the packaging project I have the following error:
System.IO.FileNotFoundException: 'Could not load file or assembly
'System.Runtime, Version=4.1.2.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified.'
InnerException: FileNotFoundException: Could not load file or assembly
'System.Runtime, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified.
My project is running perfectly if I debug it directly or run it directly using the EXE.
If I extract the files from the .appxbundle and try to start the EXE, it doesn't work either. (XXXXXX.appxbundle\XXXXXX.appx\*.*)
I noticed that in the extracted .appxbundle folder, all System.XXX DLLs are not there. They should be (94 dlls are missing).
Is there a problem with the packaging tool ?
UPDATE:
Link to dev portal: https://developercommunity.visualstudio.com/content/problem/122252/windows-application-packaging-project-tool-failed.html
This is very likely a bug in the way the packaging project is collecting files. Looks like we're already tracking this bug in the Developer Community. Also, we're tracking another related issue for ClickOnce.

Launching a Universal Windows App from WPF

I need to launch a Universal Windows app from a WPF desktop application, in Windows 10. (Actually, I need to make calls against a Universal Windows App Service, but currently, I'm having problems just getting the app launched.)
Mostly, I'm trying to follow the example here: Launch a Universal App from a WPF App.
I'm able to follow the code to create his UniversalTargetApp without problems. But when I try to "Light up Windows 10 features" by adding his references to the .csproj file, I get errors.
He says to add this to the references ItemGroup:
<!-- Light up Windows 10 features -->
<Reference Include="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.WindowsRuntime.dll</HintPath>
</Reference>
<Reference Include="Windows">
<HintPath>C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd</HintPath>
</Reference>
<!-- Light up Windows 10 features -->
But when I do, I get an error:
Multiple assemblies with equivalent identity have been imported: 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\Facades\System.Runtime.dll'. Remove one of the duplicate references.
Clearly his method of adding references to the Universal Windows assemblies worked for his version of Windows 10, or he'd not have posted his example. But also clearly, this isn't the correct method for adding references to the Universal Windows assemblies, or it'd not have broken.
I've been trying to chase down how to properly reference the Universal Windows assemblies. All I've found is this:
How to call WinRT APIs in Windows 8 from C# Desktop Applications
But that dates to Windows 8, and I've not been able to make it work in Windows 10.
Can anyone tell me the proper method for referencing the Universal Windows assemblies, so that I can call Windows.System.Launcher.LaunchUriAsync(), create Windows.ApplicationModel.AppService.AppServiceConnections, etc.?
---Edited---
As per Mehrzad Chehraz's suggestion, I removed the first two references, leaving only the last. With that, I'm no longer getting the multiple reference error. But I am still not compiling.
The following code:
var options = new LauncherOptions { TargetApplicationPackageFamilyName = TargetPackageFamilyName };
bool success = await Launcher.LaunchUriAsync(uri, options);
Generates an error:
Error CS4036
'IAsyncOperation<LaunchQuerySupportStatus>' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncOperation<LaunchQuerySupportStatus>' could be found
(are you missing a using directive for 'System'?)
Any ideas?
Remove the first two reference nodes, just keep the last one:
<!-- Light up Windows 10 features -->
<Reference Include="Windows">
<HintPath>C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd</HintPath>
</Reference>
<!-- Light up Windows 10 features -->
Launcher.LaunchUriAsync works in this way but did not tested the AppServiceConnection.
I found part of an answer here:
Load UWP library into .NET Framework app
Step 1: Add to .csproj file
<PropertyGroup>
<TargetPlatformVersion>10.0</TargetPlatformVersion>
</PropertyGroup>
Step 2: Add reference to
C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd
Step 3: Add reference to
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll

Dotfuscator CE Build Error: External type not found System.Windows.Input.ICommand,PresentationCore

I have an application targeting the .NET Framework 4.0. It builds and runs fine but I cannot get it to compile in Dotfuscator CE and they will not support it since it is CE. I am stuck.
Dotfuscator CE (v5.0.2500.0) with Visual Studio 2010 SP1. This is the Error:
Resolving method references...
External type not found System.Windows.Input.ICommand,PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
Build Error.
The problem seems to originate from Microsoft changing ICommand from PresentationCore.dll in NET 4.0 to System.dll in NET 4.5. Studio handles this and compiles fine as I am targeting NET 4.0.
Dotfuscator CE does not handle it and I am not sure how to correct the issue. Any help would be greatly appreciated.
Find the path of .NET4's PresentationCore.dll, such as C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0
On Dotfuscator's setting tab -> User Defined Assembly Load Path;
Add PresentationCore.dll's path to the path list and check the Search first.
Hope it work for you.

How do I use Microsoft.Build.BuildEngine to Build a Silverlight project?

I am using the Microsoft.Build.BuildEngine to build a number of projects. Projects that do not use Silverlight are building correctly while projects that do use Silverlight are not building. All of these projects (Silverlight and non-Silverlight) all build fine through Visual Studio 2008. I get the error message:
error CS0234: The type or namespace name 'SilverlightControls' does not exist in the
namespace 'System.Web.UI' (are you missing an assembly reference?)
I've added System.Web.Silverlight to the project that is doing the build using Microsoft.Build.BuildEngine. I am able to see that namespace in the project doing the build also (so it appears that the project doing the build does have access to System.Web.UI).
Any ideas on how I can avoid that error?
Turned up the verbosity on the build through VS2008 and compared to the log created from the Microsoft.Build.BuildEngine. It looks like the Microsoft.Build.BuildEngine is producing lines like:
Considered "c:\Program Files\Reference Assemblies\Microsoft\Framework
\v3.5\System.Web.Silverlight.dll", but it didn't exist.
It doesn't exist in that location, should it? There are actually a number of locations that it looks for that dll and doesn't find it. I added the reference by right clicking, add reference, .Net, add. There doesn't appear to be a System.Web.Silverlight.dll on my machine (which is odd because the project does compile using VS2008).
Comparing the possibly relevant sections of the two logs:
Microsoft.Build.BuildEngine
For SearchPath "{GAC}".
Considered "System.Web.Silverlight, Version=2.0.5.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL", which was not found in
the GAC.
Visual Studio 2008
System.Web.Silverlight, Version=2.0.5.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
Manually added System.Web.Silverlight to the path that the Microsoft.Build.BuildEngine was looking for it (coppied it from the output directory when I build the project via VS2008). This solved that problem, but I now get the following errors on the Silverlight components of the solution:
C:\Program Files\MSBuild\Microsoft\Silverlight
\v2.0\Microsoft.Silverlight.Common.targets(95,9): error : The Silverlight 2 SDK is not
installed.
Any ideas?
In the application that is running the Microsoft.Build.BuildEngine I changed the type of build from Any CPU to x86. This has now made the application be able to build the target as expected.
So you're programmatically building using the MSBuild APIs?
It may be useful to add an ILogger (e.g. that just prints to the console) to engine.Loggers, and compare the output with the output window in VS (after setting e.g. 'tools\options\project & solutions\build & run\msbuild output verbosity' to verbose)... seems like somehow the environment is causing assemblies to resolve differently?
Set build type of project to Any. This helps. Happy coding...

Resources