I have a C# dll compiled in .net framework 2.0 and the library is not been updated by the vendor till now. In one of my desktop application C# i was using that and when i migrated the application to WPF, the same libraries where referred and working fine. Now, the application required new diversion, as it should be upgraded to UWP and the same dll i want to make use in that also. What is the best and easiest methods available in UWP to import.Net Framework 2.0 dll ?
Regards,
Lal
You can create a .NET Standard 2.0 library project that can reference the legacy library and you can then reference this .NET Standard 2.0 project from you UWP app.
In the .NET Standard library, you can write custom types that access the legacy library and provide a "middleware layer" between the UWP app and the legacy library.
What is the best and easiest methods available in UWP to import.Net Framework 2.0 dll ?
You can not direct consume any full .NET Class Library from UWP app, there is some security restrictions. UWP project can reference libraries such as Universal Windows Class Library,.NET Standard library, Windows Runtime Component and so on.
For solving this, since your app is for desktop devices and you already have a WPF app, I recommend you to convert the WPF app to UWP app by using Desktop Bridge. Or you could try to convert the old dll into one of above the libraries that can be referenced by UWP app. If you do only want to consume the .Net framework dll, you may try to create COM Proxy Stubs and work with them as communication layer, here is the official sample.
One solution for this is to make a windows service and use that dll in service. You can reference that service from UWP application in order to make all the API calls.
Related
I have a WPF application built for .Net Framework.
It references a UWP library for doing things like using Start-Tiles etc.
I'm now converting this WPF application to .Net 6, but can't seem to find a way to call UWP methods from it.
How can this be achieved?
An application that targets and runs on the .NET Framework cannot consume a library that is compiled for UWP, like for example a library that was created using the Class Library (Universal Windows) template in Visual Studio.
You may use Windows Runtime APIs in your .NET Framework app though but that's another thing.
If you want to share code between a .NET Framework application and a UWP app, your project that contains the shared code should target .NET Standard. It can then be consumed from all applications that target platforms that is compatible with the version of the .NET Standard you are targeting in your class library.
Is there a type of c# class library that can be used/referenced by both a UWP (Universal Windows) app and a ASP.NET MVC web application?
I currently have an MVC web application that references a bog standard class library.
When I try to add a reference to that class library from my UWP or Background Application (IoT) projects it complains. I'm sure they would rather have references to Class Library (Universal Windows) project types.
Ideally i'd like a class library that can be referenced by all these project types. I presume this is not possible yet, but I thought i'd ask the question.
Is it possible? I'd rather avoid code duplication.
Do I need some sort of hacky 'include files from another folder' workaround?
Note: I have no intention of moving the web app to ASP.NET core.
I think a portable class library that targets the .NET Framework and UWP should do the job - as long as you don't want to put anything platform specific in it.
2017/18/19 UPDATE:
Creating Portable Class Libraries is now discouraged by Microsoft.
The current preferred method of sharing code between projects targeting different platforms is .NET Standard.
Take a look at the implementation support table shown on the page above. If for example your ASP.NET project is on .NET Framework 4.6.1 or above (preferably on 4.7.1-2), and you are targeting Windows 10.0.16299 with your UWP app, you can make your DLL target .NET Standard 2.0. You can simply reference that class library in both of your projects, just like you'd reference any other library.
I have a .dll that was written to target the .NET Framework. I need to create a Cordova plugin that can make calls to this .dll.
Our Cordova App runs on a Windows 10 Tablet.
Because this .dll targets .NET Framework and not .NetCORE, I cannot take the approach of a WinRT component that's suggested in all of the guidance I've seen.
Is it possible to have a Cordova plugin that makes calls to a .NET Framework .dll and if so can you recommend a correct approach?
Disclaimer: I'm in the weeds with Cordova. I'm learning as I go. An EXAMPLE would be overwhelmingly appreciated.
Thanks
No on both form and function. You'll need to use a .Net library that works with .Net Core for UWP.
Form:
Cordova apps on UWP run in the native JavaScript environment, not in a WebView hosted in a C# app. The only way for a UWP JavaScript app to call .Net functions is via a Windows Runtime Component (WRC).
While you could (in theory) write a version of Cordova for Windows Runtime that uses a .Net hosted WebView I'm not aware of any existing ones. (The Windows Phone 8 versions Hassan Ali linked do use a Silverlight WebBrowserControl, but don't run on Windows 10 tablets).
Function:
Even if you did change the Cordova host to .Net so it could call .Net directly without a WRC that would still run in the UWP context.
UWP apps can use only NetCore, not the full .Net Framework, whether they are direct .Net apps or call .Net inside a WRC.
Apache Cordova is a platform for building native mobile applications
using HTML, CSS and JavaScript
So no, you can't call .NET assemblies directly on the client. You have to put them in a plugin. You can find some samples for Windows Phone here. Another sample in this SO question.
We are using xamarin for a while now and developed different apps/libs with it. Now we need to integrate one of the core libraries/component we developed during the last years in native apps. Background: We do a project with a partner who is using native development and we need to integrate our library in his environment/his apps.
So there will be two native apps (iOS/Android) and our core library will be part of them. The question therefore: Is there a way to integrate a xamarin library (or simply C# code, written with xamarin) into the two native apps? Or do we need to completely rewrite the code in Java/Swift?
The library has no third-party libraries except ofc the .NET framework.
Thanks for sharing your experience in this matter!
AFAIK there is no way to take a Xamarin .NET library and use it in a native (Java/Obj-C/Swift) platform app.
I'm creating a library application that will act as a wrapper for an exposed API. This library ideally should work on any desktop application, but truth be told I'm intending to use this on the WP7 once I'm done creating the library.
Would this work?
From silverlight.net:
Silverlight is the application development platform for Windows Phone 7. High performance gaming is also supported through the XNA Framework.
You can't reference a .NET assembly which was compiled against the full .NET Framework in a Silverlight application.
Develop your library for Silverlight and all should be fine.