Enterprise Library Console: no Logging Exception Handler - visual-studio

I'm developing a new WPF project with C#, Visual Studio 2015 Community, .NET Framework 4.6.1 and Enterprise Library (latest version).
I'm trying to use Enterprise Library Console to add a Logging Exception Handler:
Do I have to do something to show Logging Exception handler option?
Here is my package.config file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EnterpriseLibrary.Common" version="6.0.1304.0" targetFramework="net461" />
<package id="EnterpriseLibrary.ExceptionHandling" version="6.0.1304.0" targetFramework="net461" />
<package id="EnterpriseLibrary.Logging" version="6.0.1304.0" targetFramework="net461" />
</packages>

You need to install the NuGet package for EnterpriseLibrary.ExceptionHandling.Logging. That package is what provides the connection between the Exception Handling Block and the Logging Block (it provides the ExceptionHandler that uses the Logging block).

Related

Xamarin Android Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.Compat'

I am working on Xamarin.Forms project for my company and we plan to release our app on IOS and Android (Using Visual Studio Community Edition on Macbook pro). So far everything seemed to be OK. And then suddenly I cannot build debug or release on Android project. I am getting this error:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Xamarin.Android.Support.Compat.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x00099] in /Users/builder/data/lanes/5147/c2a33d8e/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:220
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00000] in /Users/builder/data/lanes/5147/c2a33d8e/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:170
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver, System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x0015c] in <593a6fd557984367bb21e275d0fa0659>:0
at Xamarin.Android.Tasks.ResolveAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) [0x0019c] in <593a6fd557984367bb21e275d0fa0659>:0
I am pretty sure I haven't changed any source files, it was building up until now..
The only App Compat I use is "Xamarin.Android.Support.v7.Compat".
The things I tried:
Removing all packages and adding them again.
Creating fresh Xamarin.Forms project and pulling code from git - same error
Installing Xamarin.Android.Support.Compat - Error I got:
You are trying to install this package into a project that targets
'MonoAndroid,Version=v6.0', but the package does not contain any
assembly references or content files that are compatible with that
framework.
Made sure my target framework is same as target version (Use API 23) and my minimum target version is API 19.
Deleting Bin and Obj directories, restarting solution and building again.
I am using Xamarin.Forms 2.4.0.38779. I tried removing all packages and updating for the newest Forms - still got same error.
This is packages.config for Droid project:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="modernhttpclient" version="2.4.2"
targetFramework="monoandroid60" />
<package id="Plugin.PushNotification" version="1.1.2"
targetFramework="monoandroid60" />
<package id="Rg.Plugins.Popup" version="1.0.4"
targetFramework="monoandroid60" />
<package id="Xam.Plugin.DeviceInfo" version="3.0.2"
targetFramework="monoandroid60" />
<package id="Xam.Plugins.Settings" version="3.1.1"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable"
version="23.3.0" targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Design" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v4" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.CardView" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Android.Support.Vector.Drawable"
version="23.3.0"
targetFramework="monoandroid60" />
<package id="Xamarin.Forms" version="2.4.0.38779"
targetFramework="monoandroid60" />
</packages>
I will provide any logs, if needed.
So after enabling detailed build output I found the issue!
Xamarin is really bad with it's error description, and by investigating into Build Log I found out that this missing dll was required by Plugin.PushNotification NuGet package I use for both iOS and Android. After removing all references to this package from Android project, it started building again!
I have been working on Xamarin projects on my Macbook Pro for the better part of this year to know these type of issues.
This would usually happen if you copy a Xamarin project running on OSX to Windows or visa versa.
The solution is always the same. List down all the used packages in your project. Do a whole removal of the packages and reinstall them again cleanly with their specified version numbers.

Cannot install Stripe.net on PCL side in Xamarin Forms

I am working with Xamarin (Android, iOS, UWP). Stripe is my last thing to integrate, however, I can't find the way to install it in the PCL part. I could install it for Xamarin.Android and Xamarin.iOS.
The error thrown from the PCL part at the NuGet installation is the following:
Attempting to gather dependency information for package 'Stripe.net.10.4.0' with respect to project 'PROJECT', targeting '.NETPortable,Version=v4.5,Profile=Profile111'
GET https://api.nuget.org/v3/registration3-gz-semver2/stripe.net/index.json
OK https://api.nuget.org/v3/registration3-gz-semver2/stripe.net/index.json 289ms
GET https://api.nuget.org/v3/registration3-gz-semver2/stripe.net/page/7.7.0/10.4.0.json
OK https://api.nuget.org/v3/registration3-gz-semver2/stripe.net/page/7.7.0/10.4.0.json 531ms
Total number of results gathered : 20
Gathering dependency information took 826.02 ms
Summary of time taken to gather dependencies per source :
https://api.nuget.org/v3/index.json - 825.53 ms
Attempting to resolve dependencies for package 'Stripe.net.10.4.0' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'Stripe.net.10.4.0'
Resolved actions to install package 'Stripe.net.10.4.0'
Found package 'Stripe.net 10.4.0' in '/xxx/PROJECT/packages'.
For adding package 'Stripe.net.10.4.0' to project 'PROJECT' that targets 'portable45-net45+win8+wpa81'.
Install failed.Rolling back...
Package 'Stripe.net.10.4.0' does not exist in project 'PROJECT'
Executing nuget actions took 46.19 ms
Could not install package 'Stripe.net 10.4.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
I tried to change the profile to 259 without success... There is my packages :
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="portable45-net45+win8+wpa81" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="portable45-net45+win8+wpa81" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="portable45-net45+win8+wpa81" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="portable45-net45+win8+wpa81" />
<package id="PCLCrypto" version="2.0.147" targetFramework="portable45-net45+win8+wpa81" />
<package id="PCLStorage" version="1.0.2" targetFramework="portable45-net45+win8+wpa81" />
<package id="PInvoke.BCrypt" version="0.5.97" targetFramework="portable45-net45+win8+wpa81" />
<package id="PInvoke.Kernel32" version="0.5.97" targetFramework="portable45-net45+win8+wpa81" />
<package id="PInvoke.NCrypt" version="0.5.97" targetFramework="portable45-net45+win8+wpa81" />
<package id="PInvoke.Windows.Core" version="0.5.97" targetFramework="portable45-net45+win8+wpa81" />
<package id="Plugin.Permissions" version="2.0.1" targetFramework="portable45-net45+win8+wpa81" />
<package id="Validation" version="2.4.15" targetFramework="portable45-net45+win8+wpa81" />
<package id="Xam.Plugin.Connectivity" version="3.0.2" targetFramework="portable45-net45+win8+wpa81" />
<package id="Xam.Plugin.Geolocator" version="4.0.1" targetFramework="portable45-net45+win8+wpa81" />
<package id="Xam.Plugin.Media" version="3.0.1" targetFramework="portable45-net45+win8+wpa81" />
<package id="Xam.Plugin.PushNotification" version="1.2.4" targetFramework="portable45-net45+win8+wpa81" developmentDependency="true" />
<package id="Xamarin.Auth" version="1.5.0.3" targetFramework="portable45-net45+win8+wpa81" />
<package id="Xamarin.Forms" version="2.3.4.270" targetFramework="portable45-net45+win8+wpa81" />
<package id="Xamarin.Forms.Maps" version="2.3.4.270" targetFramework="portable45-net45+win8+wpa81" />
</packages>
I have reported this issue to Stripe.

Could not load type 'Xamarin.Forms.Preserve Attribute' from assembly 'Xamarin.Forms.Core'

I've just inherited an old Xamarin Forms application and I'm trying to upgrade all the packages. App was initially running fine, but since upgrading to the latest version of all packages, I'm now getting a crash calling Xamarin.Forms.Forms.Init(this, bundle);:
Could not load type 'Xamarin.Forms.PreserveAttribute' from assembly 'Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.
Here's my packages.config file contents:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ExifLib.PCL" version="1.0.1" targetFramework="MonoAndroid50" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="MonoAndroid50" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="MonoAndroid50" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="MonoAndroid50" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.Forms" version="2.3.0.38-pre2" targetFramework="MonoAndroid50" />
<package id="Xamarin.Forms.Labs" version="1.2.1-pre2" targetFramework="MonoAndroid44" />
<package id="Xamarin.Forms.Maps" version="2.2.0.31" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Base" version="29.0.0.1" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Basement" version="29.0.0.1" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Maps" version="29.0.0.1" targetFramework="MonoAndroid50" />
<package id="Xamarin.Insights" version="1.12.3" targetFramework="MonoAndroid50" />
</packages>
I closed Xamarin Studio and cleared obj and bin folders and started Xamarin Studio again and everything worked fine
I had the same issue but I noticed that the Xamarin.Forms package had an update. I updated this package and the issue went away.
I had the same message from a freshly created default Xamarin Forms app (Native, with Portable Class Library) after adding a new Form to the PCL (via the "Add New Item" context menu in Visual Studio and selecting Xamarin.Forms/Content Page).
It turned out that the packages.config in the PCL specified a different version for Xamarin.Forms than the one in UWP project.json file.
Making both projects use the same version of Xamarin.Forms by editing the packages.config fixed the problem.
The path of project must have not '#' character
In my case i had downgraded the Xamarin version from 3.x to 2.5 for all the projects. But somehow the .Net Standard project was not downgraded.
Started working after downgrading the .net standard project.

Is it safe to edit the packages.config file in Visual Studio?

I removed Microsoft.ApplicationInsights from my Windows Store (8.1) app, but it keeps coming back (with a yellow warning glyph) beneath "References". It doesn't seem to really cause much mayhem, but I'd still like to completely get rid of it out of this project.
When I remove the reference, it goes away, but then comes back later. Is it because of what remains behind in packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Callisto" version="1.4.0" targetFramework="win81" />
<package id="ExifLib" version="1.6.3.0" targetFramework="win81" />
<package id="Microsoft.ApplicationInsights" version="0.10.0-build17704" targetFramework="win81" />
<package id="Microsoft.ApplicationInsights.RuntimeTelemetry" version="0.10.0-build17704" targetFramework="win81" />
<package id="Microsoft.ApplicationInsights.WindowsStore" version="0.10.0-build17704" targetFramework="win81" />
<package id="sqlite-net" version="1.0.8" targetFramework="win81" />
</packages>
?
If so, is it safe to strip the three references to Microsoft.ApplicationInsights directly out of packages.config?
EDIT:
I removed the ApplicationInsights reference, stripped out the three references to ApplicationInsights from package.config, built the project (fine), closed the project, re-opened the project, and the dad-burned ApplicationInsight reference was back again (packages.config remained pristine).

How to add a nuget package in a MVC3 project template

I'm trying to hack a MVC 3 project template to automatically install elmah via nuget.
Since MVC 3 Tools update, MVC3 project templates contains this section :
<WizardData>
<packages>
<package id="jQuery" version="1.5.1" />
<package id="jQuery.vsdoc" version="1.5.1" />
<package id="jQuery.Validation" version="1.8.0" />
<package id="jQuery.UI.Combined" version="1.8.11" />
<package id="EntityFramework" version="4.1.10331.0" />
<package id="Modernizr" version="1.7" />
</packages>
</WizardData>
So i've tried to add elmah package like this :
<WizardData>
<packages>
...
<package id="elmah" version="1.2.0.1" />
</packages>
</WizardData>
I've also downloaded and added elmah.1.2.0.1.nupkg file in
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Packages
folder along with default packages (jQuery.1.5.1.nupkg, EntityFramework.4.1.10331.0.nupkg etc...)
Unfortunately, i keep having this error when i create a new MVC3 project :
(source: free.fr)
Does anyone knows how to solve this error?
At least is it something feasible with this version of mvc3 tools ?
I just blogged about how to do this: http://haacked.com/archive/2011/06/06/creating-a-custom-asp-net-mvc-project-template.aspx
This walks through creating and registering a custom project template.

Resources