mscorlib
is a library that contains common types used by the runtime for .NET Framework apps, but that runtime isn't used for Bridge.NET apps - it just functions as a C# -> JS/TS transpiler, so it'll just use the JS runtime ultimately.
As such any project/nuget/dll reference in your Bridge project that contains references that Bridge can't resolve will cause the Bridge compiler to throw this error you're seeing. We hit this snag a few years ago and ended up just moving any shared dependencies to Shared Projects:
https://learn.microsoft.com/en-us/xamarin/cross-platform/app-fundamentals/shared-projects?tabs=windows
Shared Projects code is compiled as part of each target project and so any dependencies will need to be resolvable to both your Bridge.NET project and your .NET project, although for simple POCO types or code that references the parts of the .NET Framework that were implemented by the Bridge team should be fine. You'll see a compiler error against the type if one of the referencing projects can resolve a dependency.
One note about serialisation (as I see you're referencing Bridge.Newtonsoft
): if your goal is to create simple serialisable types that you can transmit between the client & a server app, and if you're including type metadata in your JSON (serialised as $type
properties) you'll need to make sure that the assembly part of that type matches between your client and server.
What we ended up doing was referencing the shared project from our Bridge project, then creating a new .NET class library called {SHARED_PROJECT_NAME}.NET
that also referenced the Shared Project, then our ASP.NET web app referenced that {SHARED_PROJECT_NAME}.NET
instead of the shared project itself.
This allowed us to change the assembly name of the .NET wrapper {SHARED_PROJECT_NAME}.NET
to match the Bridge project, but without having to change the assembly name of our main ASP.NET app.
Disclaimer: Bridge.NET was abandoned by the maintainers a few years ago (Object.NET) so unless this is a programming exercise I'd recommend perhaps looking around for an alternative transpiler to avoid the pains that my company went through over the last few years.