XamarinForms CustomRenderer with .net standard 2.0 and prism7 - xamarin.forms

I am trying out Prism7 together with AutoFac in a xamarinforms project.
I am trying to create a custom renderer for an entry control, nothing fancy here.
But for some reason i cannot get a reference to xamarin.forms and xamarin.forms.platform.ios/android namespaces in my ios and android project.
The project is based on the prism7 templates and the pcl is a .net 2.0
Normally I would expect
[assembly: ExportRenderer(typeof(Entry), typeof(BorderlessEntryRenderer))]
to work and connect my renderers but as said cannot reference xamarin.forms.
Anyone got an ideer?

I made it work.
Solution was to open project in Visual Studio Mac (I was in pc version before).
Then there is no problem seeing the namespaces. Rebuild and run both projects to see them work.
Go back to visual studio pc version and continue work there. If you have Resharper you need to clear cache otherwise it will look like you still have errors.
Must be a Visual Studio Pc or Resharper bug. Maybe I should use Mac version from now on :-)

I had the same problem. That's how I fixed it:
Add the correct references (ex: using myproject.myrenderers;)
Close the solution and Visual Studio (Windows).
Delete all bin and obj folders in the solution (including each platform).
Open VS and the project.
Clean.
Rebuild.
Done.

Related

Xamarin.Forms upgraded to Maui - Visual Studio Cannot debug/run?

Application upgraded using Microsoft's auto upgrade command line tool.
Some code fixes, and the code builds successfully.
Visual Studio however does not show me any way to debug my app.
When trying to click on Debug anyway, a random Android Emulator from my list(which is not showing currently)
Will open, but deployment will fail without specifying the reason.
Has anyone managed to upgrade an existing Xamarin.Forms project to Maui?
I managed to make VS recognize the Android project in my converted solution.
I added the <SingleProject>true</SingleProject> property into my Android project's .csproj file under the first/main property group, closed VS, deleted Bin, Obj, .vs folders.
After starting VS again , I rebuilt and VS allowed me to debug on selected .net targets like a single project Maui solution.
This is very strange that it works, since this solution is made of 3 project like in a Xamarin.Forms solution, so it doesn't make since that adding this property solves the issue, but there you go.
Delete .bin and .obj folders. Delete solution's hidden .vs folder. Build. Does it show debug option now?
Try restarting VS (after the successful build). Now work?
If not, Create a new project using Maui template.
Use solution / manage all nugets to add nugets used by your project.
Copy all your source files into that new project.
Project / "Add existing items": all those source files.

Visual Studio 2019 Doesn't seem to see that I have .NET Core 3.1 Installed (with SDK)

I just installed Visual Studio a few days ago and for some reason I can't create anything but a class.
When I go to create a new User Control the pop up window lets me do everything except for click the "Add" Button to close the window and create the control.
If I double-click the User Control selector to create automatically, it pops up an alert box that says I need to go to the installer to get the .NET Framework target libraries. But when I go to the project's properties I see that I am already targeting .NET Core 3.1 and the only other option I have to target is .NET Core 3.0.... I assume this is because I'm in a .NET Core WPF application but I have no idea why it won't let me create a new control. It won't let me create anything except for a new class.
What is going on here? How can I work around this bug?
I've faced your problem recently. most of the templates were not installed after installation.
something you have to do is Modify your installation.
open Visual Studio Installer and click on Modify then choose the features(.Net core,Asp.net, Desktop Application and etc) in order to re-install them.
keep it in mind that, if installer encounters any problem or missing dll. installation instantly will be completed that should not happen.
keep your eyes close to your installer process and make sure all packages are installed.
a successful installation MUST not have any warning otherwise there are packages not installed.
it's better to install packages one by one NOT totally. I mean if you want the Asp.Net Core feature then try to install it at first. then try to install another feature.
Actually, I was not able to install whole features in a single installation and I don't know why. in short, don't heavy your installation.
If the problem still exists then:
1. Close all open solutions
2. Run InstallCleanup.exe
C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\layout\InstallCleanup.exe
3. Remove all existing Visual Studio programs from Control Panel -> program features
4. Restart pc and re-install Visual Studio
5. Make sure you have connected to the network
6. Choose only one feature(Don't select all) to install + Visual Studio Editor
vs bug
Extensions don't work properly in VS 2019 and make it hang. it's may happen because the Extensions have to be updated to be compatible with vs 2019 or it's vs bug.

Visual Studio 2015 codelens issues when using Typescript

I'm using Visual Studio 2015 Enterprise RTM.
When creating an ASP.net 4.6 web application using the Web Api template, I noticed as soon as I add a TypeScript file, the codelens indicators stop working.
I tested this on a new installation, with no extra extensions installed, as well and tried other asp.net 4.6 templates.
When running in safe mode the problem doesn't occur.
Steps to reproduce:
Set the framework to 4.6
Create a web application by using the web api template.
Change authentication to no authentication
Open the webapiconfig.cs in App_Start
The codelens indicator on the register method should say: 1 reference
Add a typescript file called app.ts (doesn't really matter) in the scripts folder, tit may remain empty
The codelens indicator in the webapiconfig file should still say 1 reference
Close Visual Studio
Reopen Visual Studio and open the solution
Check the webapiconfig file, the codelens doesn't show references anymore or on any other file
Any idea on how to debug codelens or does anyone have this problem as well?
I work for the visual studio team that is responsible for codelens references indicators. I can confirm that this is indeed a bug in VS2015 where codelens references stop working when you add typescript files to your project or typescript projects to your solution :( Unfortunately, we missed this bug for RTM. We're currently actively investigating this bug. At the moment, I am not aware of any workarounds for this problem. I can post an update when we have more information to share on this bug.
I may have found a workaround that seems to do the trick for me:
So, I have a solution with multiple projects, only one of which has TypeScript files.
I just unloaded the project, cleaned + rebuilt (some restart to Visual Studio at this point may help + close all opened files), then loaded again, cleaned and rebuilt and now CodeLens shows my references (again, close all open files).
Note that until this bug is fixed, you may have to do this each time you open VS.
Hope this helps!
EDIT: If you only have a single project, then exclude the Scripts folder from the solution, clean, rebuilt, close Visual Studio then open it again. Now you should have the references back. Simply include the folder again.
Best of luck!
in my case references start working after uninstalling vssonar extension, vs2015ent

Is it necessary to manually add <AutoGenerateBindingRedirect> metadata to the Core project file to correctly reference assemblies?

I'm using Visual Studio 2013 and MvvmCross to create an Android application using Portable Class Libraries.
I notice in my first view model, CatalogViewModel, some code is highlighted as not referencing the correct assemblies or unable to be resolved (the code builds fine even with these issues).
Examining the .NET Portable Subset assembly in the Object Browser shows various System assemblies included (2.0.5.0 v2.0.50727 & v4.0.30319, 4.0.0.0, 5.0.5.0). Automatic binding redirection for assemblies in .NET Framework 4.5.1 can be enabled or disabled by adding this line to the .csproj file.
<AutoGenerateBindingRedirect>true</AutoGenerateBindingRedirect>
or
<AutoGenerateBindingRedirect>false</AutoGenerateBindingRedirect>
This seems to solve the referencing and redirection issues in the IDE. I haven't found any information about this manual modification to the Core project file in any of the MvvmCross info online I reviewed so I wanted to post a question here to see if anyone had some information or best practices.
No, you shouldn't need AutoGenerateBindingRedirect. This feature is intended to generate binding redirects for non-platform assemblies, such as NuGet packages. Platform assemblies should be unified automatically by Visual Studio / MSBuild.
Which seems to work, since you pointed out:
the code builds fine even with these issues
So this looks like a bug in ReSharper. The fact that adding AutoGenerateBindingRedirect fixes your ReSharper issues might be a side effect of something else.

why other project reference is not showing in namespace

I have three projects in one solution (ASP.NET)
ECL.BIZ.LOGIN
ECL.MODEL.LOGIN
ECL.UI
When I added a reference to other projects in ECL.UI project, namespace is not available in using keyword. My all projects are set to .NET Framework 4 (not ClientProfile).
Why is this happening?
Note: It was working earlier smoothly, it is happening since I deleted ECL.UI project and recreate it again. After then, I still can not find namespace of other projects.
I am using Visual Studio 2012
The answer of my question is:
We have to switch between target frameworks. As I am using Visual Studio 2012, I switched my target framework to .NET 4.5 for all projects and add the reference for required projects and switch back to .NET 4 again for all projects at same time. Then it works absolutely fine as I expected.
Note: I don't know why it is not working while all other projects are set to same framework even after recreating one of the project. However the above trick worked for me. If anyone having this weird problem after deleting one of their project and recreating it again, you can try the above on your own. Thanks to all

Resources