I converted one of our commonly used libraries to .NET standard 2.0 for mobile application use as well as use in existing applications.
Using this library in an existing Mvc application (4.7.1 Framework) it builds and runs successfully but the Visual Studio IDE reports a list of build errors for the controller classes around not being able to find elements of the library. The using clause of this library is also greyed out in the controller classes.
Is there an easy way to resolve this?
Upgrading from MVC 5.2.3 to 5.2.6 has solved.
Related
We have a dozen of Asp.Net/WCF applications that we would like to migrate to SDK style. All of them use PackageReference, so that is not a problem.
We do not want to develop our own dotnet build SDK and we are not in a position to migrate to Asp.Net Core/gRPC.
This question is a follow up to Is it possible to use the Microsoft.NET.GenerateAssemblyInfo.targets with a non Sdk style project? - at the end of the day we were able to migrate most of the projects to SDK style and now we want to migrate the WCF/Asp.Net ones.
EDIT
I would like to elaborate on the expectations from such an SDK. As far as I understand, a WCF/Asp.Net project has a few features that have to be addressed:
The publishing logic implemented in Microsoft.WebApplication.targets
The default recognition of certain file extensions. For example, **\.html, **\.css, **\.js should be automatically included as Content, just like in the regular SDK **\.resx are automatically recognized as EmbeddedResource.
Certain assembly references could be added automatically, but this is not a big deal.
Just handling these items would make our day.
If I understand your question correctly..
If you are in position to package your SDK as a new .NET Core dlls / packages while keeping all existing WCF as they are, you could:
Create .NET Core SDK project
Add WCF service references to your SDK project
Allow Visual Studio to generate proxy code
Code against your WCF from the .NET Core calling your services via proxy objects generated
Here is Microsoft team's guidance:
https://learn.microsoft.com/en-us/dotnet/core/additional-tools/wcf-web-service-reference-guide
I have a visual studio solution that has several projects in it.
Solution
Domain Layer (Class Library > .Net Core 2.2)
Holds all the database models
EntityFramework (Class Library > .Net Core 2.2)
Holds all the interaction with the database. I reference Microsoft.EntityFrameworkCore and Oracle.EntityFrameworkCore
Presentation Layer (WPF Windows Application > .Net Core 3.1)
Is the main interaction for the application
I'm at the point where I need to integrate reporting and printing of reports. I've always used Crystal Reports for my applications (with good success). However, since Crystal requires Framework 4.5 I can't figure out how to make that work.
I've created my Reporting objects and tested them. They work great in their own standalone solution. Once I reference the Framework app in my Core app I break. In particular I break when I attempt to create a Crystal 'ReportDocument' object . I've seen all over SO (and tested) you can't mix a .Net Core with .Net Framework because of the different DLLs.
Any suggestions on how I can get reporting/printing to work? I'm not picky when it comes to Crystal Reports either.
You are out of luck, because it is not supported. I would encourage you looking into other alternatives
From the Crystal Reports vendor website:
So update your Core Project to the full 4.7.1 and it should work. I just install 4.7.1 and it works for my existing ASP.NET project that was set to 4.0.
To be clear, Framework 2.0 Core is NOT supported
Source: Crystal Reports in ASP .NET Core 2.0
How about you rethink your approach a bit. Do you really have to bundle everything to a single monolithic application?
Have you considered some separation of concern? What I'm trying to say is that you can abstract away your reporting service to a separate project/service and pass the data you need over let's say the wire - as an example.
Then you can build your application logic as you please.
My line of though is:
sln
UI
API ?
Domain
Infra
sln
API (wcf/gRPC/REST)
reporting service
Also you might want to consider gRPC, it can probably integrate with your legacy code if you have any.
https://learn.microsoft.com/en-us/dotnet/architecture/grpc-for-wcf-developers/migrate-wcf-to-grpc
https://github.com/dotnet-architecture/eBooks/tree/master/archives/grpc-for-wcf-developers
https://www.youtube.com/watch?v=76X9oo-LlUY
As you are probably aware, Microsoft has deprecated the Portable Class Library (PCL) in Xamarin and replaced it with the .Net Standard class library instead.
I have a couple of older Xamarin projects that use a PCL, but I have started a new project using the .Net Standard class library this week.
Each project needs access to a RestAPI.
A RestAPI could be added to the PCL projects through an easy to use menu as below, and generate the client for me. The .Net Standard project is missing this menu.
Does anyone know how to get this menu back or another way to generate the RestAPI for the .Net Standard projects?
The API for this new project is likely to expand very quickly and change frequently, at least in the early days of development so I wish to avoid having to write it myself (as the Xamarin guide on their site suggests doing).
I am currently using AutoRest to generate the API classes and models to use in Xamarin but i feel this is only a work around as currently to get it to generate correctly I had to use an old version of AutoRest (0.13.0) and an old version of Microsoft.Rest.ClientRuntime(1.8.0) which i copied from a completely different project and run with a BatchFile pointed to a .json file generated from the api.
PCL
.Net Standard
I am creating a solution using ASP.NET Core 1.1 (SDK 1.0.4) and I require to use System.DirectoryServices namespace.
According to this Github issue
they are porting those APIs from the .Net Framework in the upcoming 1.2 version. However, I have seen that you can create an ASP.NET Core app targeting the full .Net Framework. I have follow some tutorials but all of them seem to be outdated (.Net Core 1.0 using project.json) and I have found no way to make it work.
In the same manner, I have seen some Github projects that seem to run ASP.NET Core and System.DirectoryServices namespace using something called DNX (like this one ). However, this project also fails in Visual Studio 2017.
Is there any real solution to have access to System.DirectoryServices on ASP.NET Core?
There might be a hacky way to go about it, but I haven't explored this enough, yet. I have noticed that when you create an "ASP.NET Core Web Application (.NET Core)" project, it doesn't allow you to change the .NET framework version to anything but available .NET Core versions. You'll need to create an "ASP.NET Core Web Application (.NET Framework)" project in order to use the full framework.
If you've already got an existing project you're working on, the best thing I can recommend is to simply create a new "ASP.NET Core Web Application (.NET Framework)" project and migrate your existing code over to that. For the most part, it should just be copy-and-paste. Like I said, there might be some other way, that I just don't know, but you at least have that method.
FWIW, DNX was .NET Core, before it was ".NET Core". There was a somewhat similar setup where you could run DNX on full .NET or just the "core" .NET functionality. It doesn't really help you here.
The difference between my question and previously asked questions is that I don't mind having .NET 4.5 installed on the server or the development environment. However, I don't currently intend to change the target framework of my original 4.0 projects in the solution. I wish to have only one new project that targets .NET 4.5 and have one of the other 4.0 projects call it.
I tried to add existing item and 'Add as Link' as described here but that didn't help.
Can my purpose be implemented anyhow? I don't mind adding a web service to one of my projects if that would be a resolution.
An assembly/application that is targeted to 4.0 will not be able to make calls to classes/methods in 4.5. If you cannot update the targeting to 4.5, then splitting your app into two separate apps and using webservices would work, as long as your client application doesn't need the 4.5 framework to consume those services (e.g. a data type only in the 4.5 framework.)