Compile time error when attempting to upgrade ServiceStack from 4.6.3 to 5.5.0 while Targeting .NET 4.7.2
The error suggests you still have a dependency that's referencing an incompatible ServiceStack.Interfaces build. This is typically due to having dependencies that reference both .NET Framework and .NET Standard builds of ServiceStack packages within the same project in which case you'll need to multi-target your .NET Standard projects.
It could also be due to a version mismatch. Note all dependencies should be referencing the same version version number for all ServiceStack packages, i.e. they all should be referencing the same 5.x
version. You can also try deleting the /bin
and /obj
folders to force a clean restore and build.
The type is defined in an assembly that is not referenced, how to find the cause?
When you get this error it isn't always obvious what is going on, but as the error says - you are missing a reference. Take the following line of code as an example:
MyObjectType a = new MyObjectType("parameter");
It looks simple enough and you probably have referenced "MyObjectType" correctly. But lets say one of the overloads for the "MyObjectType" constructor takes a type that you don't have referenced. For example there is an overload defined as:
public MyObjectType(TypeFromOtherAssembly parameter) {
// ... normal constructor code ...
}
That is at least one case where you will get this error. So, look for this type of pattern where you have referenced the type but not all the types of the properties or method parameters that are possible for functions being called on that type.
Hopefully this at least gets you going in the right direction!
ServiceStack using DotNetStandard Service Model in .Net framework web project
If you want to support both classic ASP.NET Framework project and a .NET Core project you need to multi target. See this previous answer for details:
https://stackoverflow.com/a/49417944/85785
If you just want to support an ASP.NET Core .NET Framework project and a .NET Core project (I.e. both ASP.NET Core projects) you can reference ServiceStack’s *.Core projects which only contains .NET Standard builds.
Alternatively you can avoid the binary coupling of sharing your ServiceModel.dll project and have the classic ASP.NET projects reference your DTOs via C# Add ServiceStack Reference.
How can I use a Service Model from ServiceStack 4.0 in a ServiceStack 5.0 Project?
Please read the existing links from this answer:
https://stackoverflow.com/a/51252374/85785
TL;DR you can’t share the same .dll, you either need to multi-target or decouple the binary dependency by using C# Add ServiceStack Reference.
Other solutions is having old Framework projects Reference the old compiled ServiceModell.dll (alternative to multi targeting) or just copy the source code of the DTOs you need (alternative to C# Add ServiceStack Reference).
Could not load type from assembly error
Is the assembly in the Global Assembly Cache (GAC) or any place the might be overriding the assembly that you think is being loaded? This is usually the result of an incorrect assembly being loaded, for me it means I usually have something in the GAC overriding the version I have in bin/Debug.
Add service from another dll of another solution
The AppHost supports wiring up Services from multiple .dll's so you can register services in an external .dll by adding the assembly to your AppHost's base constructor:
public class AppHost : AppHostBase
{
public AppHost()
: base("App",typeof(MyServices).Assembly,typeof(ServiceInExtDll).Assembly){}
public override void Configure(Container container) {}
}
Related Topics
Rounding Up to 2 Decimal Places in C#
Binding Datagrid to Observablecollection<Dictionary>
C# Gui Refresh and Async Serial Port Communication
Why Does Computing Factorial of Relatively Small Numbers (34+) Return 0
Why Does Environment.Exit() Not Terminate the Program Any More
Where to Find "Microsoft.Visualstudio.Testtools.Unittesting" Missing Dll
Differencebetween Streamwriter.Flush() and Streamwriter.Close()
Wait for File to Be Freed by Process
C# Quickest Way to Shift Array
What Is the Best Battleship Ai
Using Bindingoperations.Enablecollectionsynchronization
When Should I Create a New Dbcontext()
How to Return the Current Action in an ASP.NET MVC View
Learning Single Responsibility Principle with C#
What's the Difference Setting Embed Interop Types True and False in Visual Studio
Datetime2' Error When Using Entity Framework in VS 2010 .Net 4.0