ServiceStack4+LLBLGen4.2: Templates will not compile 'ServiceHost' is undefined - rest

We are a licensed user of ServiceStack and I am using the latest version. I've created an LLBLGen project and added the latest ServiceStack LLBLGen templates. I am able to generate the LLBLGen projects, but the XXXXProject.Services class library fails to compile:
Error 1 The type or namespace name 'ServiceHost' does not exist in the namespace 'ServiceStack' (are you missing an assembly reference?) C:\PROJECTS\ServiceStack\XXXXService\XXXXService.ServiceModel\DAL\ServiceGeneric\Validators\VendorValidator.cs
Are the templates compatible with ServiceStack v4? If not, do you know when they will be compatible or what I need to change to make them work with the latest version of ServiceStack?
Thanks,
Mike

Related

How to restore nuget packages for Autofixture.NSubstitute for .net6 projects type?

Not able to restore packages for AutoFixture.AutoNSubstitute in package. This was working fine earlier but now I am not able to build the solution. Projects are using .NET 6. Unit tests inside solution which are using this project are giving error like
Error CS0234
The type or namespace name 'AutoNSubstitute' does not exist in the namespace 'AutoFixture' (are you missing an assembly reference?)
C:\FILEMAN\test\AStorage.Core.Tests\AutoSubstituteDataAttribute.cs 8 Active
I am not able to add the nuget package when I tried adding the nuget package through the Manage Nuget packages .
Please let me know how I can fix this.

How does .NET resolve different versions of the same package?

This question pertains to .NET 5+, not .NET Framework.
Consider the following dependency tree:
MyWebsite has package references to RandomWebLibrary 1.0.0 and RandomJsonLibrary 2.0.0.
The NuGet package RandomWebLibrary 1.0.0 has a package reference to RandomJsonLibrary 1.0.0.
The NuGet package RandomJsonLibrary has no dependencies.
My questions:
What version(s) of RandomJsonLibrary will be loaded at runtime?
What happens if RandomJsonLibrary 2.0.0 has a completely different API than RandomJsonLibrary 1.0.0?
Can the author of MyWebsite do anything to fix problems that arise from having multiple versions of RandomJsonLibrary in the dependency tree? Is there an equivalent of .NET Framework's binding redirects in .NET 5+?
I'm asking out of curiosity, not because I am encountering a problem. For reference, here is the documentation on Understanding AssemblyLoadContext which seems relevant but did not answer my question.
These questions are answered by the documentation page How NuGet resolves package dependencies. The "Dependency resolution with PackageReference" section is what's relevant to this question since we are talking .NET 5+.
When the package graph for an application contains different versions of the same package, NuGet chooses the package that's closest to the application in the graph and ignores all others. This behavior allows an application to override any particular package version in the dependency graph.
In the example below, the application depends directly on Package B with a version constraint of >=2.0. The application also depends on Package A which in turn also depends on Package B, but with a >=1.0 constraint. Because the dependency on Package B 2.0 is nearer to the application in the graph, that version is used:
To answer the original questions:
RandomJsonLibrary 2.0.0 will be loaded at runtime.
I believe RandomWebLibrary will throw exceptions at runtime if RandomJsonLibrary 1.0.0 and 2.0.0 have incompatible APIs.
The author of MyWebsite can choose the exact version of any dependent package by installing that package directly into MyWebsite. In the case of RandomJsonLibrary, the author of MyWebsite should probably downgrade to RandomJsonLibrary 1.0.0 to prevent RandomWebLibrary from breaking. AFAIK there are no binding redirects in .NET 5+.

Link SDK only + Entity Framework = System.ComponentModel build error

With linking set to SDK Only, I have an error on iOS like this:
MTOUCH : error MT2101: Can't resolve the reference 'System.Void
System.ComponentModel.DataAnnotations.AssociatedMetadataTypeTypeDescriptionProvider::.ctor(System.Type)',
referenced from the method
'System.ComponentModel.ICustomTypeDescriptor
System.Data.Entity.ModelConfiguration.Utilities.AttributeProvider::GetTypeDescriptor(System.Type)'
in 'System.ComponentModel.Annotations, Version=4.3.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
I use Entity Framework and a number of other 3rd party libraries that integrate with Entity Framework, and in the past I have needed to add a --linkskip argument for System.Core or a .Init call in my Appdelegate file for Sqlite, but these techniques havent helped me with this ComponentModel issue. I assume it's because of Entity Framework or one of the related 3rd party libraries I'm using since I know they use a lot of reflection. Has anyone run into this before?
EntityFrameworkCore.Triggers 1.2.2
LinqKit 1.1.17
Microsoft.Data.Sqlite.Core 3.1.6
Microsoft.EntityFrameworkCore 3.1.2
Microsoft.EntityFrameworkCore.Design 3.1.3
Microsoft.EntityFrameworkCore.Relational 3.1.2
Microsoft.EntityFrameworkCore.Sqlite 3.1.2
Microsoft.EntityFrameworkCore.Tools 3.1.3
Z.EntityFramework.Plus.EFCore 3.0.69
The projects using entity framework are class libraries that target .netstandard 2.0, and my main application uses xamarin forms 4.5 (have tried updating to 5.0 with no success)
I solved this problem manually referencing System.ComponentModel.Annotations.dll in .netstandard2.1 in nuget folder. You can try first to install the Annotations Nuget e if doesn't work you can try to manually reference.

Azure Devops Services Pipeline build fails. Builds successfully through Visual Studio and the msbuild command prompt

I have solution with 2 projects both targeting .Net Framework 4. The solution builds successfully in Visual Studio 2015 and 2017 as well as the msbuild command line.
However, when it builds in Azure DevOps Pipeline with Agent Specification vs2015-win2012r2 the first project fails with the following errors. The NuGet restore step shows it successfully installed the NuGet EntityFramework 5.0 package.
The type or namespace name 'Infrastructure' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?)
The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'DbModelBuilder' could not be found (are you missing a using directive or an assembly reference?)
When I change the Agent Specification to vs2017-win2016 the first project builds without error but the second project fails with the following errors:
The type or namespace name 'Description' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?)
The type or namespace name 'Http' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
Error CS0234: The type or namespace name 'Http' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)
I do have the NuGet package Microsoft.Asp.Net.WebApi.Core.4.0.20710.0 referenced in the csproj file which contains the System.Web.Http.dll.
I have turned the debug option on. Here are links to the NuGet Restore Log https://drive.google.com/open?id=1lJWflXTjYTN_MQyLOnwMUr-8LKoR5JRo
and the Build Log
https://drive.google.com/open?id=1ypAVWxniDLfBOBHc4gODdAoQOCQnphYg
According to your log, there is a warning message.
warning MSB3267: The primary reference "System.Net.Http", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "System.Net.Http" or retarget your application to a framework version which contains "System.Net.Http".
Some differences are in effect when executing a command on a local machine and when a build or release is running on an agent. If the agent is configured to run as a service on Linux, macOS, or Windows, then it is not running within an interactive logged-on session. Without an interactive logged-on session, UI interaction and other limitations exist. And there are some troubleshooting steps which was provided by Microsoft.
There is a simple method that you can try to resolve the error. Delete the reference under the project's references, and then juse add it back in again.The reference was to a namespace in a local project to the solution. For some reason it was being found locally but not found when checked into and built on VSTS.

Build fails in Release mode but works fine in Debug - Entity Framework 6.0 related issue

I build my application and run it in debug mode. Everything is ok. I can test the functionality and everything is working. Its a multi tier MVC application using Entity Framework 6.0.
Now, when I change the build from Debug to Release and build the projects. I get a few hundreds build errors. All the errors are in the Data Access layer where I use the Entity Framework 6.0. The errors are in the form of:
Error 388 The type or namespace name 'DbSet' could not be found (are you missing a using directive or an assembly reference?)
Or
Error 201 The type or namespace name 'Schema' does not exist in the namespace 'System.ComponentModel.DataAnnotations' (are you missing an assembly reference?)
I have tried cleaning the solution and rebuilding but always same. Not sure why this can happen? Any suggestion will be appreciated.
many thanks