Skip to content

Instantly share code, notes, and snippets.

View brendanzagaeski's full-sized avatar

Brendan Zagaeski brendanzagaeski

  • Microsoft
  • Boston, MA, United States
View GitHub Profile
@brendanzagaeski
brendanzagaeski / Metadata.xml
Last active December 7, 2021 14:22
Some Metadata.xml fixes for binding the Socialize Android SDK (http://getsocialize.com/sdk/) in Xamarin.Android
<metadata>
<!-- Some Metadata.xml fixes for binding the Socialize Android SDK (http://getsocialize.com/sdk/) in Xamarin.Android
Note that this is not a complete set of fixes. These changes only address the first round of compile errors. -->
<!-- Fixes for duplicate EventArgs, as discussed on:
http://docs.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/#Problem_Duplicate_custom_EventArgs_types
Error message: Error CS0102: The type `SomeClass` already contains a definition for `p0' (CS0102) -->
<attr path="/api/package[@name='com.socialize.auth.twitter']/interface[@name='TwitterAuthListener']/method[@name='onError' and count(parameter)=1 and parameter[1][@type='com.socialize.error.SocializeException']]" name="argsType">AuthTwitterErrorEventArgs</attr>
<attr path="/api/package[@name='com.socialize.facebook']/interface[@name='Facebook.DialogListener']/method[@name='onComplete' and count(parameter)=1 and parameter[1][@type='android.os.Bundle
@brendanzagaeski
brendanzagaeski / gist:9417060
Last active January 8, 2019 09:25
NullReferenceException in ClientRuntimeChannel constructor on Xamarin.Android 4.12

To solve both of the problems from the stack traces below, follow these steps:

  1. Add the following to an XML file in the project:

    <?xml version="1.0" encoding="utf-8" ?>
    <linker>
    	<assembly fullname="System.ServiceModel">
    		<type fullname="System.ServiceModel.Channels.ChannelFactoryBase`1">
    
    
@brendanzagaeski
brendanzagaeski / gist:9378181
Last active February 11, 2016 21:16
Xamarin.Android.Support vs. Mono.Android.Support: use Xamarin.Android.Support
Recommendation: use the Xamarin.Android.Support.* components instead of the Mono.Android.Support.* libraries
As discussed on [1], the Xamarin.Android.Support.* components are now recommended over the Mono.Android.Support.* libraries. One reason for this is that the Xamarin.Android.Support components can be updated more frequently to keep pace with new releases from Google. Eventually, the Mono.Android.Support will be removed from Xamarin.Android. All new code should use the Xamarin.Android.Support libraries.
[1] https://bugzilla.xamarin.com/show_bug.cgi?id=15205
## Xamarin.Android.Support components in binding projects
At the moment, there's a limitation with using Xamarin.Android.Support components in Xamarin.Android Java binding projects. Specifically, the bindings projects do not yet "know" how to automatically reference the `.jar` files used by the components. This leads to error messages like:
@brendanzagaeski
brendanzagaeski / AndHUDNullCheck.patch
Created March 5, 2014 20:42
Patch to prevent NullReferenceException in AndHUD
diff --git a/AndHUD/AndHUD.cs b/AndHUD/AndHUD.cs
index 2022fcb..6d57870 100644
--- a/AndHUD/AndHUD.cs
+++ b/AndHUD/AndHUD.cs
@@ -222,10 +222,12 @@ namespace AndroidHUD
}
else
{
- Application.SynchronizationContext.Post(state => {
- progressWheel.SetProgress (progress);
@brendanzagaeski
brendanzagaeski / gist:9337026
Last active April 18, 2020 10:27
Prevent the Xamarin.Android bindings generator from converting a get or set method to a property
# Prevent the Xamarin.Android bindings generator from converting a `get` or `set` method to a property
Xamarin.Android Java bindings projects will by default automatically bind any Java method that starts with "get" to be the getter of a C# property. To prevent this in specific cases, you can set the `propertyName` attribute of the method to the empty string. The same is true for methods that start with "set", except that they will only be converted to property setters if there is already a corresponding property getter. This requirement prevents the creation of set-only properties (see also http://msdn.microsoft.com/en-us/library/ms229006.aspx).
So for example, you would add something like the following to the Metadata.xml file:
```
<attr path="/api/package[@name='com.example.testandroidlib']/class[@name='MyClass']/method[@name='getNumberTen']" name="propertyName"></attr>
```
@brendanzagaeski
brendanzagaeski / XamarinVSiOSAppStore.md
Last active May 8, 2018 02:34
A couple ways to submit (publish, upload) a Visual Studio Xamarin.iOS app to the App Store

A couple ways to submit (publish, upload) a Visual Studio Xamarin.iOS app to the App Store

Option 1: upload an IPA created via the "Build Adhoc IPA" command

  1. Pick the "Ad-Hoc" build configuration.

  2. Change the provisioning profile in "project options -> iOS Bundle Signing" to an AppStore provisioning profile.

  3. Rebuild the project.

@brendanzagaeski
brendanzagaeski / gist:8602459
Created January 24, 2014 17:53
Some steps to try if Xamarin Studio says "Error updating Xcode project. Invalid parameter"
# Some steps to try if Xamarin Studio says "Error updating Xcode project. Invalid parameter"
1. Quit Xcode and Xamarin Studio.
2. Delete the `obj/` folder where Xamarin stores the generated Xcode files (or just the `obj/Xcode` folder, if you prefer)
3. Open the project in Xamarin Studio, and build the project.
4. Try to open the problematic XIB (or storyboard) file.
@brendanzagaeski
brendanzagaeski / FetchRepositoriesWithCompletionArgsAction.cs
Created January 10, 2014 06:16
Example of a generated Task return value for `[Async (ResultTypeName = "FetchRepositoriesWithCompletionArgs")]`, using `Action<bool, NSError, NSArray>` as the delegate type. This results in generic return value names like "Arg1".
public class FetchRepositoriesWithCompletionArgs {
public bool Arg1 { get; set; }
public NSError Arg2 { get; set; }
public NSArray Arg3 { get; set; }
public FetchRepositoriesWithCompletionArgs (bool arg1, NSError arg2, NSArray arg3) {
this.Arg1 = arg1;
this.Arg2 = arg2;
this.Arg3 = arg3;
}
@brendanzagaeski
brendanzagaeski / FetchRepositoriesWithCompletionArgsNamed.cs
Created January 10, 2014 06:12
Example of a generated Task return value for `[Async (ResultTypeName = "FetchRepositoriesWithCompletionArgs")]` using a named delegate. The names of the return values match the names of the delegate's arguments.
public class FetchRepositoriesWithCompletionArgs {
public bool Success { get; set; }
public NSError Error { get; set; }
public NSArray Repositories { get; set; }
public FetchRepositoriesWithCompletionArgs (bool success, NSError error, NSArray repositories) {
this.Success = success;
this.Error = error;
this.Repositories = repositories;
}
@brendanzagaeski
brendanzagaeski / XShellUninstallVS.txt
Created December 14, 2013 00:18
Fixing the Xamarin installation after uninstalling the "Xamarin Shell" extension from "Tools -> Extensions and Updates" in Visual Studio
If you uninstall the "Xamarin Shell" extension from "Tools -> Extensions and Updates" in Visual Studio, you will get a "'ShellPackage' package did not load correctly" error even after uninstalling and re-installing both Xamarin VS extensions.
## Cause
Uninstalling the "Xamarin Shell" from "Tools -> Extensions and Updates" sets a value on [1] named "Mono.VisualStudio.Shell,1.0", with the data:
C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\COMMON7\IDE\EXTENSIONS\XAMARIN\SHELL\1.0.0\
[1] Computer\HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\ExtensionManager\PendingDeletions