Xamarin aar binding. Many class declaration missed - c#

I'm trying to accomplish the .aar file binding to the Xamarin Android project.
I used Bindings Library (Android) project, include my aar to there and build. Everything went Ok.
In Xamarin Android project I added a reference to the generated .dll
It appeared to have only a couple of interfaces exposed but the aar has tons of classes surfaced for sure (I can see them in Android Studio).
Where are the other classes and members?
What I did:
I modified my Metada.xml as following (to expose private declarations and suppress obfuscation). Please ignore its "(" brackets, it is for correct display.
<metadata>
<attr path="/api/package[#name='com.android.biomini']/class[#name='BioMiniAndroid']"
name="visibility">public</attr>
<attr path="/api/package[#name='com.android.biomini']/class[#name='BioMiniAndroid']"
name="obfuscated">false</attr>
</metadata>
It did not help. How to make it show me all classes and interfaces the .aar has?
Thanks.

You are on a correct path to fix these issue by making the types public.
There are bunch of reasons why JAR file classes/member are not accessible in the Xamarin.Android project, you can read about there reasons and possible solutions here
I recommend reading JAR binding documentation for better understanding

All that had been read inside out. No solution found.
The problem appeared to be a Xamarin bug. Xamarin recommendation is not to reference it to a binding project but copy .dll to somewhere aside and reference to there (via "Browse" referencing, not "Solution" one). Even though it is awkward it works. It is a viable solution for now.
Thanks.

Related

Self-built C# Library not found

I have an issue including a self-built library to a C#-project. I have created an own class library called ClassLibrary1 just to learn how to add libraries on Visual Studio 2019.
So I have written some simple code in a newly created .NET-class library project and have clicked on "create new solution" (directly translated from my german IDE-language. Maybe it's called slightly different) after writing the code. Back in the C#-project, I have selected the dll-file from bin/Debug/ of the class library's project folder.
After I have set the checkmark, the dll-file was shown in the solution-explorer under Assemblys like expected. But the issue I now have is that I still cannot use the ClassLibrary1.dll-file in the cs-file in this very project as I expected via the command "using ClassLibrary1;". It only shows me the error message "type- or namespacename "ClassLibrary1" not found" when trying to compile the C#-project and I don't get, why this is the case.
It seems like it has to be a very obvious problem but after some research on the internet and trying some things by myself still nothing has changed.
Thanks in advance for helpful replies.
The by far easiest way to manage a library is to use project references. Ensure that your library and the project that uses the library is in the same solution. Then right click the "references" and select "add Reference", go to the project tab and add a checkbox for the library. Read more about managing references.
You might also need to add namespaces for the classes you wish to use in the source files.
I would not recommend managing using file-references to lose dll-files, since it can easily become a hassle to manage. I.e. if you create a new version of the library you would need to build, and explicitly replace this file in all other projects and update all the references.
If you want to share libraries between multiple solutions the more popular solution would be to setup a nuget server. This solves some of the updating problems by maintaining multiple versions of the same library, and provides a nice interface to update references in all projects. But this is a somewhat more complicated solution, so I would not recommend this for new developers.

MissingManifestResourceException with Silverlight application referencing resx files in other project

I'm having difficulty getting a Silverlight application working. The project is quite large, and was recently handed to me. It consists of (among other things):
A class library containing resources (let's call this MyResources). This contains a number of .resx files that contain translated strings for various labels/text in the app.
A Silverlight class library that links to all the resource files in the regular class library. (let's call this project MyResourcesSilverlight)
A Silverlight app that references MyResourcesSilverlight
From what I understand, with Silverlight you can't directly reference a regular .Net assembly because of security concerns. This makes sense, and explains the two nearly identical projects - the Silverlight class library and the regular class library. (There's a bunch of other projects that use the regular class library).
The problem I'm having is when I'm attempting to run the Silverlight app, it is failing to load any of the localized strings, and I'm getting the following error message:
Uncaught Error: Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "MyResources.resources" was correctly embedded or linked into assembly "MyResourcesSilverlight" at compile time, or that all the satellite assemblies required are loadable and fully signed.
From the error message, it would appear that it is having difficulty pulling in the resource files - and this is also apparent from the missing text on buttons, labels, etc.
To fix this, I've tried doing the following:
Cleaning/rebuilding the solution. This had no effect.
Right clicking on the resource files and selecting "Run Custom Tool". The Custom Tool for all the resource files is set to PublicResXFileCodeGenerator. This has no effect as well, other than regenerating the code, which causes the class constructor to be internal (despite being set to public. Another problem for another day - or from what I've seen - a known issue that Microsoft is refusing to fix).
Setting all the resource files to Embedded Resource. This had no effect.
I've been looking around at other people who have had this similar issue, and have tried pretty much anything I can get my hands on, but nothing seems to work. Either I get the error message above, or I get an error message like The name 'MyResources' does not exist in the current context..
If it helps to know, the project was originally a Visual Studio 2010 project, but I've converted it to be a Visual Studio 2012 project. To the best of my knowledge, nothing has changed namespaces, which is a common cause of this problem.
Can anyone shed some light on what might be happening here? I'm quite stumped.
EDIT:
Perhaps also worth noting: I'm not seeing any sort of text on any of the forms in the Visual Studio designer. When I mouse over the supposedly missing StaticResource, it says "The resource ___ could not be resolved.". I suspect this may be an indication of a larger problem with the resource files in general. Anyone have any thoughts?
I eventually got this sorted out, but I'm still not 100% sure on what I did to fix it. This is what I did, though:
Because of the odd layout with the two library projects, whenever I would touch the MyResources project, it would automatically update the MyResourcesSilverlight project. This meant that if I did the "Run Custom Tool" on MyResources, it would regenerate the resource designer files with a namespace of MyResources. If I then went into the MyResourcesSilverlight project and did the "Run Custom Tool" on the resources there, it would then rebuild the files with the MyResourcesSilverlight namespace.
When I started digging through the XAML files that were having issues, I noticed that they were referring to things like so:
xmlns:resources="clr-namespace:MyResources.Resouce;assembly=MyResourcesSilverlight"
This made me look twice at the namespace in the files being generated inside the MyResourcesSilverlight project. Sure enough, when doing the "Run Custom Tool" on the resource files, it was generating them in the MyResourcesSilverlight namespace rather than the MyResources namespace. I set the default namespace on the MyResourcesSilverlight project to MyResources, then did the "Run Custom Tool" again to regenerate the auto-generated code. Despite manually setting the auto-generated code to create things as public, I still had to manually go in and switch the class constructor from internal to public. Once I did that, things seemed to start working.
So if I were to sum this up, I'd say look at the following:
Verify the namespace that your XAML files are using and the namespace of the auto-generated code in the resource files. They should match.
Verify that the constructor of the auto-generated code is public. Don't trust the Custom Tool.
Hopefully this helps out anyone else who might be stuck on a similar issue.

Why am I getting bad references to AxWMPLib?

I've got a couple of classes that use the AxWMPLib.MediaPlayer control, and I've just migrated all of my classes into a single library ( from a couple of windows forms projects ).
The problem I am having is that even after exposing references to the MediaPlayer COM Object, I am still getting 'missing assembly' errors for this namespace.
I wonder if there is anything that must be specifically done in a 'Class Library' project to include these references, or if I am just totally overlooking something obvious...
Suggestions for my seeming incompetence would be much appreciated...
Imported the DLLs directly from my original project ( which had been copied to the output directory in my original build ).

Grid is not supported in a Windows Presentation Foundation (WPF) project

I am learning how to create a Class Library (Windows Store apps) and used a UserControl template to add a user control to it.
Then I added a Grid tag to accompanying XAML. However, the tag is underlined with blue squiggles and when I hover over the tag there is
Grid is not supported in a Windows Presentation Foundation (WPF) project
tooltip shows up.
The library seems to build without errors. I've added the library to an application and use the control in its code. The application is also builds just fine. However, when I run the application I get XamlParseException exception.
I am using Visual Studio 2012 RTM. Both the library and the application reference only two standard assemblies (.NET for Windows Store apps and Windows).
What I might done wrong and how should I fix the library?
In my case I switched from Debug to Release, and then back, and the error was gone.
Go to "Build > Configuration Manager..." and Make a new platform for x86 for all your projects.
It doesn't have to be the active one, you can leave that as Any CPU.
Hope it works as for mine...
I've recently had the same error and found the following in the output window:
10>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFX.targets(268,9): error MC6000: Project file must include the .NET Framework assembly 'WindowsBase, PresentationCore, PresentationFramework' in the reference list.
The solution for me was to add the missing references to my project.
For me it helped to set the "Target framework" in application-properties to .NET 4.0
This appears to be a bit of a "catch-all" for a number of XAML resource errors. I've found two causes so far:
Declaring a Resource outside of the appropriate context- e.g. directly in a UserControl tags, not UserControl.Resources.
Forgetting to include the correct namespace for the "unsupported" class. Example in a basic ResourceDictionary, with no sys namespace defined:
<ResourceDictionary>
<sys:string>I'm not supported</sys:string>
</ResourceDictionary>
I was able to solve my similar issue of..
UserControl is not supported in a Windows Presentation Foundation (WPF) project
.. by removing the PresentationFramework reference and re-adding it via nuget.
[Reposting comment as answer]
I was able to complete the steps with no issues, and it appears you were able to as well. Perhaps there was some other inadvertent modification/setting that was made?
This is xaml getting itself confused. I have the error on one project and not on another. Have a look at the top of the xaml before the grid error and see if there are any references to other controls. Try making a modification that will cause and error and rebuilding one of those controls. Then put it back the way it was to get a succesful build and see if this makes the grid error go away. (it did for me)
Much Like Felix D.s answer, I found from the .csproj file a reference was removed.
Obviously replace the 3 with your needed framework, or use the project properties to set the version ( i think that adds this reference )
Evil Dog Pie was step 1 for me, as some other issues came up. There is always a heap of information in the output log
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
This problem is due to the low version of .NET that you have chosen in your project.
To solve the problem, select the Project from the up menu and then select your Project Properties and from the part of Target Framework select higher version of .NET Framework!
I hope your problem is solved.
Yours sincerely

Class Library Intellisense not showing up after adding the dll to the references

In C#, I made a ClassLibrary that has one Namespace and one Class.
I saved it and build it.
in other Projects, when i use it, I add it to my references by browsing to the .dll location.
But The Problem is that its name is not showing up in the Intellisense.
i.e when I: using ... my dll doesn't show ..
I'm Importing the library to a ConsoleApp.
both of the App and the library target Framework is .NET Framework 4.0
and I made their Assembly Version 4.0.0.0 so they're the exact same.
is there a setting or something that I'm missing ?
how can i make it pop up ?
I'm using VS2010 Professional
Thank you for your help
Maybe this be usefull, I was having a similar issue, I have a Web project, add the reference to a Class Library by selecting the project, but if I made a change on the class library, I canĀ“t see that change on the intellisense of the Web Project, after try many things, I see that in the recently added reference, the value of the option "Local Copy" was set "True", then I change it to false and everething works!
I had a similar issue but in my case it was a property on the class. If you go to the file properties and look for a Build Action. Somehow mine was set to Content it had to be set to Compile.
I am using Visual Studio 2013. I hope this helps someone else.
Is the namespace for your assembly different than the namespace for your currently open project? I've had times when the current project and an assembly share the same namespace path the intellisense can mess up.
In general, Visual Studio is pretty good about intellisense generation, especially for C#. But sometimes there are some interesting conditions regarding ambiguities, and especially mixing project types where it just doesn't quite work.
Placing your content in the same namespace makes me wonder if you've actually fixed the problem (it may just be autocompleting the namespace in the currently loaded project rather than the assembly), but if it allows you to continue working, then go with it!
Right click on project on which you add reference of your dll/project select menu project dependancies and select/MarkCheckBox for reference project/dll. then it will work fine.
If the class library project had its name changed after creation, then intellisense may fail finding it due to directory issues, I believe.
I created my class with the generic "ClassLibrary1" or whatever, and then later changed the default namespace, class name, and project name inside of VS2017. I closed VS2017 and changed the directory name to match my default namespace, and then re-associated the project file in VS2017, and then re-added the reference in my main project file.
All seems to be fixed now.

Categories