I'm developing a cross platform app in Xamarin.iOS and Xamarin.Android. I want to write a dal or repository layer once, and then make a reference to it from Android and iOS yo layers. Is this possible? Thanks.
This kind of thing is not possible for 1.x, as the API is not compatible with any PCL or .NET Standard profile (however, you can use shared projects to achieve something similar). However, version 2.0 of the library is compiled as .NET Standard 1.4 and so you can create one assembly that can be referenced by any platform that also implements at least .NET Standard 1.4 (including Xamarin iOS and Android).
Related
I have to use a SDK that targets uap10.0.x from a windows application.
I have tried adding Microsoft.Windows.SDK.Contracts and Microsoft.Windows.CsWinRT but it gives build error Failed CLR.
I did some research and discovered a way to add uap in TargetFrameworks.
https://developercommunity.visualstudio.com/t/net-core-cross-target-with-uap/174053
After I did this, I got errors for Windows.Forms and other libraries.
I also tried creating a .net standard library and add the reference there. The build was successful but I got runtime error for Platform not supported when using the library inside the net5.0 app.
I also tried creating compilation constants to only use the library in windows os but the error was the same.
What is the way to go in this case? Is it possible to use a uwp library inside windows app or should I create a uwp project and find a way to start it from the windows app.
Any suggestion is appreciated.
Is it possible to use a uwp library inside windows app ...
No, if the SDK only targets the uap10.0 target framework moniker (TFM), you cannot use it in an app that targets any other framework than UWP.
A TFM, such as for example uap10 or netstandard2.0, specifies a set of APIs that are available to the library or app. If you want to be able use the SDK from both UWP and .NET apps, it should target .NET Standard.
Please refer to the docs for more information about target frameworks and TFMs.
I have a standard WPF application developed in .Net framework 4. Now, my client wants a website which I am planning to develop using .Net Core. In order to share the business logic, I need to move the database along business layer to a separate project and here I am planning to use .Net Core. So, all the layers i.e. Data/ Business/ API will be re-written using latest version of .Net Core.
Would I be able to reference business layer written in .Net Core from WPF (.Net Framework 4) project?
Any pointers will be highly appreciated.....
You should implement the common functionality in a .NET Standard library. You will then be able to reference this assembly from all apps that are compatible with the version of the .NET Standard that your common project targets.
The various .NET implementations target specific versions of .NET Standard and the following table on MSDN lists all versions of .NET Standard and the platforms supported: https://learn.microsoft.com/en-us/dotnet/standard/net-standard.
The latest version of .NET Core (currently 2.0 at the time of writing) implements .NET Standard 2.0. The oldest version of the .NET Framework that implements .NET Standard 2.0 is 4.6.1. This means that your WPF app should target 4.6.1 to be able to consume a .NET Standard 2.0 assembly.
.NET Core 1.0 and .NET Framework 4.5 support .NET Standard 1.0.
The .NET Framework 4.0 doesn't support any version of .NET Standard though so you should re-target your WPF app against (at least) .NET Framework 4.5.
Would I be able to reference business layer written in .Net Core from WPF (.Net Framework 4) project?
The answer is yes. You can try it: In Visual Studio create a WPF application project and a .NET Standard library project and then add a reference from the application project to the library project.
There will be NuGet packages that you cannot reference in your .NET Standard project because they only support full .NET Framework but most popular NuGet packages can be referenced from a .NET Standard project. Your question is also tagged [entity-framework-6]. If you want to use Entity Framework from a .NET Standard project you will have to use Entity Framework Core as Entity Framework 6 requires the full framework.
You should probably create a quick spike to determine if you can build your application how you intend to.
I have .Net Winform project(c#) working in windows.Now,i want to do same project, to work as OSX App in Mac. As per my understanding Microsoft recently launched Visual studio for Mac preview and also it support OSX app development using Xamarin.Mac and also it support .Netcore .
Instead of creating Osx app from scratch,i need to reuse the code which is available in .net winform project.
can i develop UI application using .netcore project? I think .netframework and .netcore more or less same.can i port .netframework to .netcore project and create osx app ?
or
can i use xamarin.mac and reuse the .netframework c# code to create osx app?
I am new to this,so kindly suggest the best way to create OSX app using Visual studio for Mac preview. (Basically i need Tabel view,form controls and graph(there i use zedgraph).Is these view are available here.
In general, the "standard" way of developing cross platform applications is to separate as much of your logic as possible into shared libraries of some type and create "thin" UIs specific to each platform.
Depending on your need, you could easily make that shared code netstandard/PCL/etc compatible and share between platforms or just recompile the project in each solution.
NSTableView will likely solve your needs, but expect it to be significantly more primitive that what you are used to on Windows. Graph controls don't come built in, so you'll need to find a vendor that ships Cocoa controls or draw them yourself.
Here is the quickstart documentation.
Xamarin.Forms support for macOS is coming in the future, currently earmarked for Q2 this year.
I've been trying to sort this out for some time now..
I have a few .NET libraries that work as an SDK to an external application. I need to use that SDK both from a WPF Class Library and a Silverlight Class Library. I've been reading a lot of solutions including:
Portable Class Libraries - When I try to add the SDK libraries to the project, it complains that those libraries reference .NET 2.0 libraries and it is incompatible.
WCF RIA - I may be doing this wrong, but everywhere I turn, one step of the process is to create an Entity with the EF. Now, I don't want to access a DB, just those libraries.
But so far, no luck. Any ideas you would like to share?
As far as I know, it may not work if the old .NET 2.0 binaries have references to COM or system libraries. That could relate to your DB implementation. I have had this problem in a project in a previous job. We solved this by creating a WCF service as a in-between solution. That was WCF and not WCF RIA.
If the .NET 2.0 code is really old, you should check if it must be compiled as x86 and hosted as a 32-bits application on AppPool of the site that hosts the WCF service in the IIS.
But this is tricky business, and it all depends on the complexity of the old .NET 2.0 library file and its references.
I have an existing C libraries which uses Win32 API but it is not supported in windows 8 metro store apps.
I tried calling WinRT API but failed so is there any way ican use WinRT apis in C.
Since the question although very general seems to be specifically about SHGetSpecialFolderPath() on WinRT I'll address this:
As you found out WinRT (Metro) apps run in a sandboxed environment which only supports a limited subset of the win32 api.
SHGetSpecialFolderPath is officially deprecated on MSDN and its functionality is not available to WinRT applications. The closest equivalent would be the ApplicationData class. Unfortunately calling it from C is complicated. I would recommend writing a C++ helper which your library could call into.