Unable to run dotnetprojects WpfToolkit - datagrid

I have a project which still uses Xceed WPF Toolkit DataGrid, and I want to upgrade it to https://github.com/dotnetprojects/WpfExtendedToolkit.
I have unistalled the Xceed nuget and installed this one: https://www.nuget.org/packages/DotNetProjects.Extended.Wpf.Toolkit/
Once done that, I have removed these two lines from my XAML:
xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
And replaced them with these other two ones:
xmlns:xcdg="clr-namespace:Xceed.Wpf.DataGrid;assembly=DotNetProjects.Wpf.Extended.Toolkit"
xmlns:xctk="clr-namespace:Xceed.Wpf.Toolkit;assembly=DotNetProjects.Wpf.Extended.Toolkit"
But it does not work. Both namespaces are not found in the assembly.
Anyone can help me to setup this, please?
Thank you

Related

IntelliSense & .NetCore

I've been using .NetCore for some smaller projects and I generally love it, but there are a few issues, of which one has been irritating me quite a bit:
In this example a lot of the configuration stuff uses extension methods to hang extra features off of Json, Command Line, Object Binding etc... In these cases all of which live in separate packages. When you see some code examples which typically include one or more of them you naturally copy them into a project to try them out, giving you compile errors when you try to build them.
Asking VS for guidance (pressing good old Ctrl Dot), doesn't help and so you have to search for the relevant packages you need followed by more searches in Nuget installing each one as required.
So my question is (Drum Roll Please) am I missing something or is there a tool/setting or extension that can give me suggestions based on exported extension methods on Nuget's public packages when you press Ctrl Dot on the error much like suggestions on missing namespaces?
Regards
Lee
If you are targeting netcoreapp2.1 you can use the metapackage which will include all of "supported" packages from Microsoft.
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/metapackage-app?view=aspnetcore-2.1

Xamarin.iOS project: CS1703: Multiple assemblies with equivalent identity have been imported

I've got a cross platform (iOS and Android) Xamarin solution using .NET Standard 2.0. The solution is being built by Visual Studio 2017 (I've tried both the current and preview versions). The Forms and Android projects build fine. However, the iOS fails to build, with the following error:
1>CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Users\newuser.nuget\packages\system.reflection.emit\4.3.0\ref\netstandard1.1\System.Reflection.Emit.dll' and 'C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.Reflection.Emit.dll'. Remove one of the duplicate references.
I've tried many work arounds as described here:
oren.codes
www.hanselman.com
github.com/NuGet
Unfortunately none of these suggestions work. I have also tried to add the System.Reflection.Emit nuget package directly to the Forms and/or to the iOS projects directly. This doesn't work either. Note that originally, the The System.Reflection.Emit package wasn't referenced directly by anything in the solution. It is being pulled in by the following nuget packages which are being explicitly referenced:
Acr.DeviceInfo (5.0.5)
akavache (6.0.0-alpha0038)
AutoMapper (6.2.2)
Microsoft.Identity.Client (1.1.1-preview0040)
Newtonsoft.Json (10.0.3)
Finally, I have tried the update-package -reinstall command in the package console to reinstall all packages for the iOS project. This doesn't work either.
-- update
Just to make this clear, neither the Xamarin Forms or the Xamarin iOS project directly reference System.Reflection.Emit. That package is being pulled in as a dependency of other nuget packages, just from packages that are installed into the Xamarin Forms project. I have confirmed all of the dependencies that are referenced by Nuget, are using the same version. See these screenshots:
It seems to me that the problem (as the error says) is that there is an old version of System.Reflection.Emit that was installed by Visual Studio. However, I can't find a way of ignoring it and using the version of System.Reflection.Emit instead. As I've said above, I have tried to use a project.json file in the Xamarin.iOS project, and manually ignoring, but this doesn't work.
Does anyone else have any ideas?
As an aside, I notice that this bug is still open for Xamarin.
Xamarin Bugs
Managed to get this resolved thanks to an answer by #DirkWilhem on Xamarin Forums site.
Basically, add this to your Xamarin iOS project's .csproj file, with the other PackageReference nodes:
<PackageReference Include="System.Reflection.Emit">
<Version>4.3.0</Version>
<ExcludeAssets>all</ExcludeAssets>
</PackageReference>
Of course you need to make sure the nuget package has been added to the iOS package first.
Xamarin Forums discussion
After spending hours trying to resolve this myself I may have found a solution. Although it does feel wrong, it has got me past the issue.
Moving/Deleting the Xamarin.iOS version of System.Reflection.Emit.dll has solved the build problem for me and enabled me to deploy and run my app on a device. I don’t know what side effects it might have so will need more testing but I thought I’d share what’s worked for me so you can test it as well.
I was running on macOS Visual Studio 2017 but switched over to Windows to try and fix and first fixed on there then tried same approach on macOS and it worked as well.
On windows, go into the following directory and move the System.Reflection.Emit.dll somewhere else (you could just straight up delete it but I wanted to keep a copy I case this has some undesired effects down the track):
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades
On mac the following directory has it:
/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Facades
Like I say, it feels wrong but for now it’s got me past an issue that’s had me blocked for a couple of days so willing to just move on and hope there’s no side effects. I’d be interested to know your experience with it and if you come across anything else for the future too.
I’ll post this same comment on the Xamarin forums post (https://forums.xamarin.com/discussion/120814/xamarin-ios-project-cs1703-multiple-assemblies-with-equivalent-identity-have-been-imported) as well for future reference.
I had the same issue around a custom Nuget packages that we created and consumed in a separate project. We got around this issue by removing the automatic Nuget building checkbox in the "options" for the project. This does add the extra step of "Create Nuget Package" but one we pushed it to our Nuget repo and consumed it in our project, the errors vanished.
The problem showed up when we updated the sub-projects from PCLs to .netstandards (2.0).

Cannot Build Xamarin.Forms From Source Code

I have downloaded the Xamarin.Forms solution from GitHub and I am trying to build the solution. Visual Studio does not build, generating more than 70 errors, as simple as the one below:
"The type or namespace name 'IOnClickListener' could not be found (are
you missing a using directive or an assembly reference?"in
Xamarin.Forms.Platform.Android\AppCompat\ButtonRenderer.cs
When I investigate the code, I see that there is really no reference to Android.Views.View in the using statements, so it seems fair.
Am I making a mistake somewhere?
It's not easy to get to the answer without digging into the logs but here are some steps that have helped me in the past.
Android Specific Steps:
Check the logs for any problems that stand out, look at the top most error first and work your way down. Output window -> Show output from Xamarin Diagnostic
If you find unzipping problems you might have to visit the Xamarin folders to delete the zip causing problems and Xamarin will download a new one.
C:\Users{USER}\AppData\Local\Xamarin
If you get loads of Xaml and Resource errors you might have to delete the contents of the file.
Resources\Resource.Designer.cs
After deleting the content(not the file), clean the solution, rebuild the project.
If you still have problems try to either downgrade Xamarin.Forms or upgrade it.
Change Api level to a higher one on the project properties.
Hope one of these helps.

Can not find system.web.http

I have to add a system.web.http assembly reference because I added the HttpConfiguration class to my unit test class library project.
When I browse the Add reference dialog I can not find the system.web.http assembly.
The class library project has the .Net 4.5.1 framework targeted.
in order to get the system.web.http you will need to install a nuget package
in the nuget command line:
Install-Package Microsoft.AspNet.WebApi.Core
https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Core/
I've had multiple errors regarding missing references such as "system.web.http" or "system.web.razor" in my project. Even though I do have all the references installed through nuget.
What worked for me was to install a standalone version of AspNetMVC4, even though Visual Studio 2014 installed that as well. Apparently it was missing some references in Windows. I've installed this from the Microsoft website, and all went well afterwards.
Hope this helps someone. It drove me crazy for like 2 days, nothing regarding nuget worked for me, I've deleted and reinstalled the references a couple times, did everything I've found in multiple posts on stackoverflow, nothing worked.
Url for mvc4 standalone setup from microsoft: https://www.microsoft.com/en-us/download/confirmation.aspx?id=30683
For every one haveing this problem. Remember that you might have a downgraded version of based on your framework. Try look on your packagde folder what version you have. Then upade that version. Dont use Update-Package it will update all version with no respect to the framework your running at all.
It was solved by commenting out the "bindingRedirect" part.
bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0"/

EntryPointNotFoundException - Entry point was not found when loading an MVVM Light View in Expression Blend 4

I'm posting this question so I can document the solution as I found it very tricky and time consuming to solve.
I'm using Laurent Bugnion's excellent MVVM Light Toolkit in a Silverlight 4 project and I'm using his ViewModelLocator pattern with the Microsoft.Practices.ServiceLocation.ServiceLocator to load design time models for Blendability. Initially loading the Views up in Expression Blend 4 was working and the design time data binding was great. This stopped working at some point without any error message in Blend at all.
I used Visual Studio 2010 SP1 to attach to Blend.exe to debug the issue. The EntryPointNotFoundException (Entry point was not found) exception was being thrown at this line of code:
return ServiceLocator.Current.GetInstance<ExampleViewModel>();
Strangely enough, I was able to load the same View in the Visual Studio XAML Designer successfully with my design time data binding working correctly. I used another Visual Studio instance to attach the debugger to the Visual Studio instance hosting the XAML Designer and was able to confirm that the ServiceLocator call was executing successfully.
The exception detail (stack trace, InnerExcetion etc) did not give me any further clue to the problem and various Internet searches for the unhelpful error emssage failed to shed any further light.
I eventually got lucky by using the Visual Studio Immediate Window to execute part of the line of code that was causing the problem and got a much better error message:
?ServiceLocator.Current
The type 'Microsoft.Practices.ServiceLocation.ServiceLocator' exists in both 'Microsoft.Practices.ServiceLocation.dll' and 'Microsoft.Practices.ServiceLocation.dll'
Comparing the changeset to previously working code I noticed that I had added a reference to GalaSoft.MvvmLight.Extras.SL4 in a separate Unit Test Framework for Silverlight project (which references the UI project). This test project was referencing the assembly from C:\Program Files (x86)\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\Silverlight4 where as the UI project was referencing it from ..\packages\MvvmLightLibsPreview.4.0.0\lib\SL4. I had used the nuget package MvvmLightLibsPreview to add MVVM Light to the client project.
The Blend Results - Errors and Output Windows did not show any error message at any point. Obviously there is no real answers required unless there are some Blend trouble shooting techniques which would have helped my figure out the problem faster.
I had almost the same issue though my problem did not go away until I uninstalled MVVM Light using the Windows 7 control panel. The NuGet MVVM Light references were still in the project but now I can see the design time data. It was broken before.
I followed the advice on the MVVM Light web site and attached the Blend preview for Visual Studio 2012 and received the error that you mentioned above (EntryPointNotFoundException). I had no idea even then that I should try to remove two different versions of MVVM Light that were conflicting with each other.
AS you would expect, changing the test project's MVVM Light assembly references to use the same nuget package versions used by the client UI Project fixes the problem. I've no idea why Visual Studio did not have a problem with two versions of the Microsoft.Practices.ServiceLocation.dll being referenced in the same way as Blend.
I ended up trying to copy over the entire contents of the package that would come from NuGet into
C:\Program Files (x86)\Laurent Bugnion (GalaSoft)\Mvvm Light
Toolkit\Binaries
That did not solve the problem.
Since uninstalling MVVM Light took away other things such as snippets, I decided to go back and troubleshoot some more. I was not successful and could only find a rough temporary solution.
I tried comparing projects that would work and projects that would not work by looking at the four DLL files:
GalaSoft.MvvmLight.Extras.WPF4 GalaSoft.MvvmLight.WPF4
Microsoft.Practices.ServiceLocation System.Windows.Interactivity
I don't see any differences in versions.
So, the work around for now is to start a new project using the MVVM Light WPF template in Visual Studio 2012, build it, then remove references to the four DLL's mentioned above. Then I install the package MVVM Light from NuGet and edit out the double entry of the view model locator in App.xaml and then the program works fine. At this point I can see the design data message on the Main window which says
"Welcome to MVVM Light [design]"

Resources