Xamarin Android Archive Library (aar) binding. SharedPreferences issue - c#

I try to create a xamarin binding project for aar library. But if I add interface or class which extends SharedPreferences, it is not compiled. How to fix this?
See screenshot with logs below
I also created a project to demonstrate the issue.
https://github.com/3akat/SharedPrefsXamarinBindingIssueDemo

Related

How to use class from other project in visual studio C#

I have a Xamarin.Forms project and a C# console app project. I want to use one class from the console app in my Xamarin.Forms project.
I added the console app project to the solutions explorer of the Xamarin.Forms project.
Unfortunately, I can't figure out how to use the class from the console app in one of the Xamarin files.
I always get the error message:
The name 'MyClass' does not exist in the current context.
I tried to press alt+enter to show potential fixes but it does not offer me the option of importing/using the class.
I also wrote manual using directives in various forms but it still does not seem to make the class accessible.
The only way I was able to use the class was by adding the class directly to the Xamarin project by adding it with add->existing item. The problem with this is that it imports a copy of the class. Since I'm still working on the class within the other project the added class is fast outdated and I have to manually copy its contents over.
How can I use a class from an external project without making a copy of the file?
Instead of access class from console app(its exe) try creating new reusable library add that class and use in both projects also you can write wrapper class in both projects
Try to add a reference to the second project in your first project. To do this, right-click on your project, select Add Reference then select the project in your solution. Once your main project references the second project, then you can access its public types.

Xamarin.Forms iOS crash on XAML pages with custom controls

I am working on a Xamarin.Forms project, for which I recently upgraded the shared projects from PCL to .NETStandard.
At that point, I encountered build issues coming from several of my UI XAML files, with the error being:
Failed to resolve assembly: ‘MyAssembly, Version 0.0.0.0,
Culture=neutral, PublicKeyToken=null’
The problem files were found to be those that referenced custom XAML controls. After finding several people with similar issues online, I eventually found that I could get past this issue by setting the XamlCompilationOptions for those pages from Compile to Skip. The project now builds for iOS and Android.
The Android version works normally, however for the iOS version crashes when one of those pages tries to load, due to the presence of the custom control, with an error such as:
Xamarin.Forms.Xaml.XamlParseException … Type shared.SharedControl not
found in xlmns clr-namespace: …
Has anyone encountered this issue, and if so, did you solve it? Is it a code issue or a Xamarin / Visual Studio Mac bug?
Ideally I would like to not have to set the XamlCompilationOptions for those pages to Skip, but either way I don't see why it should affect iOS but not Android.
Firstly, XamlCompilationOptions.Compile means Compile the XAML for the class or project when the application is built.While XamlCompilationOptions.Skip do the same thing when the application is run on the device.
In addition ,I suggest that you can do following steps:
Delete and Re-generate all share files
Remove ;assembly:xxx from App.xaml
Clean and build again.
Here is a similar thread for you referring toXamarin.Forms.Xaml.XamlParseException has been thrown
PS:There is a link about how to Upgrade PCL to .NET Standard Class Library
You need to load that assembly before using it. On Xaml it does not load, just try to reach, and crashes if its not loaded. Before using it you need to load assembly by calling a method, or creating an object belong MyAssembly.
There should be a Init method for the assembly to init things. you should call it.

PLC - PC communication using Snap7 in C# WPF app

please, I have a question about snap7.dll library. So long time I wanst be working in C#, so maybe I am doing something wrong. But is possible to use snap7 in C# WPF project as library or it was developed only for windows forms? Its stupid I know, but I am asking because I am not able to add snap7.dll into my project references. Thank you.
Downloaded and played around with the examples from http://snap7.sourceforge.net/
Looks like the console application doesn't reference the assembly directly.
This isn't a WPF vs Winforms thing. It is a managed vs unmanaged code thing.
There is a snap7.net.cs .net wrapper class file.
It references "snap7.dll" and exposes its functionality as a C# class. At runtime it will load the assembly using DllImport.
Copy both the snap7.net.cs file and the snap7.dll into your project.
Use the snap7 class methods/attributes in your code. Then update snap7.dll to copy to output directory, or use a post build event to copy the snap7.dll to your output directory.
EDIT: I want to restate you do NOT add reference to the snap7.dll directly using project -> references. The DllImport annotation of the wrapper class file will load it at runtime.

xaml won't see external library classes

I'm following this tutorial from Microsoft to use a Portable Class Library in a Windows Phone 8.1 WinRT Project. At the end they show an example in WPF.
It works well with WPF, you can use a class from the external library in the xaml for example to set the d:DataContext property of the window.
However with Windows Phone app, after adding the namespace alias in xaml, intellisense won't find the classes, and compiler insults me.
I found a workaround by creating dummy classes in the app project namespace, like this:
namespace App
{
public class dummyClass : externalLibrary.externalClass
{}
}
Using this, intellisense works.
Any idea how to fix this?

Mono Library is not updated

Thank you for reading my question.
I am updating a third-party library. My goal is to add a new control.
I seem to have added a new class to the namespace containing the group of controls, which I am trying to extend.
However, when I try to link again my "now extended" library, I don't see my new control.
Where does Xamarin Studio get the information regarding the classes contained inside a resource DLL? Is it from an mdb file?
Also, when I compile my library, DLL is created fine and mdb is not created. Is this OK?
Please advise.
Thank you
While I could not figure out how to find out from Xamarin Studio where is each/in-question listed library located on the disk, edit references menu has an option to specify the location from which the newly referenced assembly is loaded. This worked.
Thanks.

Categories

Resources