Having trouble referencing .NET Standard class library using SQLProvider from .NET Core project - .net-core

Reproduction of problem here: https://github.com/Arrow7000/SqlProviderTest
I'm fairly new to the .NET world so am having trouble wrapping my head around exactly what the problem is.
I've tried to use the SQL type provider directly in an F# .NET Core project, but had a bunch of problems getting it to work. From what I can tell that's due to incompatibilities between .net core and type providers.
So what I am trying instead is to have the SQL type provider code encapsulated in a .NET Standard project that I can reference from my main Core project.
I've managed to reproduce the problem in a minimal GitHub repo located here which demonstrates both that
the type provider is working in Visual Studio 2019 with IntelliSense, but
despite this I still get a build error when I try to start the Main project
The build error is
Unable to find the file 'C:\projects\SqlProviderTest\SQLStuff\bin\Debug\netstandard2.0\SQLStuff.dll' in any of
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\ref\netcoreapp2.2
C:\projects\SqlProviderTest\Main
C:\Users\Aron\.nuget\packages\fsharp.core\4.6.2\lib\netstandard1.6
Why isn't the project reference simply working as expected? I've tried adding <Private>True</Private> to the project reference but that didn't make any difference
P.S. in case it matters, I'm developing on Windows but the app gets deployed on a Docker container.

Related

.net standard library with HttpCient for xamarin forms

I was trying to create a common library for using HttpClient to consume an API. I was planning to make it in .net standard so as to share it with my xamarin.forms project right now and any future ones. However the highest version of .net standard I managed to use was 1.0. HttpClient needs standard2.0. I have included the latest version of .netstandard nuget into my xamarin.forms.
I have noticed that xamarin.forms runs in net4.5. According to the documentations the max I can go with this is standard1.1. Is there any work around around these to a .net standard common project or is my only option to make a .net framework project/xamarin portable library?
I used to be in the same situation and I managed to pull through this. First I tried to upgrade my current PCL project to .netStandard, but it was always failing, so I decided to create a new Project A Class Library (.NETStandard), moved all my files to the new project and re-install all nuget packages.
New project configuration:
Target Framwork: .NET Standard 2.0
Output type: Class Library
Make sure you're using Microsoft Visual Studio > version 15.3
Hope it helps.
I did manage to get HttpClient working in .net standard after manually importing the class. It needed an additional reference which is why it threw an error when I downgraded from .netcore.
This seems to work sometimes and throws reference errors other times. These errors go when I close and re-open visual studios.

Azure Web App with assembly containing C++/CLI

I have some existing functionality in unmanaged C++ which I wanted to use in a Web App. This code was already wrapped in C++/CLI and used via desktop C# apps. So there is already an existing mixed mode .NET assembly containing the functionality I want to use in a Web App. I also already have Azure hosted web apps that are composed of assemblies containing only C# and I can publish them from Visual Studio 2017 to an Azure App service with no problem.
So I tried to add the mixed mode assembly and started getting errors from the publish about the dependencies of the mixed mode assembly. The only dependency of the mixed mode assembly is on the VC++ runtime so I assumed that was the problem. To prove this I created an Azure VM started IIS on it and published to that and got exactly the same error. I then installed the VS 2017 C++ runtimes on the VM and published again. The error went away and the Web site works fine.
I them logged onto the machine hosting the Web service using Kudu and it appears to have the VS 2017 C++ run time already installed. So I am baffled why I get the error when I publish to it. I have tried adding the runtime DLL's like vcruntime140.dll to my publish but this didn't fix things. I also tried re-installing the runtimes with no luck.
So does anyone have any insights as to why I am getting DLL dependency errors and what I can do to fix it. Ideally I was hoping for a Hello World example of using C++/CLI in a Web App from Microsoft but have not been able to find one.
Note there is a similar question here multi-file c++/cli .net assembly in ASP.NET web site without an answer.

What is the purpose of Microsoft.AspNetCore.Razor.Tools?

What is the purpose of Microsoft.AspNetCore.Razor.Tools?
I'm using visual studio code on os x
From the git hub page https://github.com/aspnet/RazorTooling I can see
The Razor syntax provide a fast, terse, clean and lightweight way to combine server code with HTML to create dynamic web content. This repo contains tooling that interacts with the DNX Design Time Host to provide a Razor editing experience.
Does visual studio code use this assembly? What is a DNX Design Time Host? When would I need to include this assembly in a project?
I found a reference to it in the project.json of a web application project that I generated using yo aspnet.
At least here: https://www.nuget.org/packages/Microsoft.AspNetCore.Razor.Tools/ you can see a brief description of library:
TagHelper tooling for .NET Core CLI. Contains the dotnet-razor-tooling
command used to resolve TagHelperDescriptors for projects at
design-time.
And here you can find a bit more details: https://docs.asp.net/en/latest/mvc/views/tag-helpers/intro.html#intellisense-support-for-tag-helpers
On mac you can run the same command:
dotnet razor-tooling
but it doesn't make any sense because for now VS Code doesn't provide any intenseness for Razor views. So probably you can remove this dependency from project.json.

Is it necessary to manually add <AutoGenerateBindingRedirect> metadata to the Core project file to correctly reference assemblies?

I'm using Visual Studio 2013 and MvvmCross to create an Android application using Portable Class Libraries.
I notice in my first view model, CatalogViewModel, some code is highlighted as not referencing the correct assemblies or unable to be resolved (the code builds fine even with these issues).
Examining the .NET Portable Subset assembly in the Object Browser shows various System assemblies included (2.0.5.0 v2.0.50727 & v4.0.30319, 4.0.0.0, 5.0.5.0). Automatic binding redirection for assemblies in .NET Framework 4.5.1 can be enabled or disabled by adding this line to the .csproj file.
<AutoGenerateBindingRedirect>true</AutoGenerateBindingRedirect>
or
<AutoGenerateBindingRedirect>false</AutoGenerateBindingRedirect>
This seems to solve the referencing and redirection issues in the IDE. I haven't found any information about this manual modification to the Core project file in any of the MvvmCross info online I reviewed so I wanted to post a question here to see if anyone had some information or best practices.
No, you shouldn't need AutoGenerateBindingRedirect. This feature is intended to generate binding redirects for non-platform assemblies, such as NuGet packages. Platform assemblies should be unified automatically by Visual Studio / MSBuild.
Which seems to work, since you pointed out:
the code builds fine even with these issues
So this looks like a bug in ReSharper. The fact that adding AutoGenerateBindingRedirect fixes your ReSharper issues might be a side effect of something else.

Adding project reference in visual studio

I added a project reference of my Business Logic project to my console application. I can reference the project and its classes in the code of my console application. Weirdly, when I build the project, the build fails and the classes which referenced says Type is not defined.Has anybody come across an issue like this?
You have to import name space in your console application class where you are trying to use the business logic application class.
I have selected the incorrect target framework .net framework client profile 4.0 where it should be .net framework 4. Issue rectified and now I can build the project.

Resources