Xamarin.IOS MvvmCross App throws NullReference Exception in ViewDidLoad method in iOS9 - c#

I am working on an existing Xamarin iOS application with a PCL and uses MvvmCross for IoC and Databinding. Built on MvvmCross 3.1.1
The App looks like a TabControl App but it is buttons on the MainViewCotnroller giving the Tab feel to it. Views are declared in the Storyboard and in the MainViewController,
PrepareForSegue(UIStoryboardSegue segue, NSObject sender) method
is overridden to load the selected "Tab" View based on the Segue selected - like below
if (segue.Identifier == "FirstSegue")
{
var dest = segue.DestinationViewController as FirstView;
dest.Request = new MvxViewModelRequest<FirstViewModel>(null, null, new MvxRequestedBy());
foreach (UIView v in src.placeHolderView.Subviews)
{
v.RemoveFromSuperview();
}
dest.View.Frame = new CGRect(0f, 0f, w, h);
src.placeHolderView.Add(dest.View);
}
The App runs fine on iPhones with iOS 7.1 till 8.4.
Just before iOS 9 was released I did a test installation for the App on iPhone 6 with iOS 9.1 beta and the App crashed on loading. I retrieved the device logs (below) and analysed that the problem is in the guts of the MvvmCross ViewDidLoad method. I updated the latest SDKs (XCode 7, Xamarin.IOS 9.0) and followed instructions provided by Xamarin and compiled the App again using the latest SDKs same error. Updated the Nuget package reference for MvvmCross to 3.5.1 and still the same issue
The issues is there is a null reference at Line 44 in the 3.5 MvvMCross Source Code in GitHub
Note: This piece of code has not changed since 3.1 at least and 3.5.1 is the latest in the nuget for MvvmCross
Stack Trace below (App Names, Project Names changed for security reasons):
2015-09-21 11:06:26.991 MyApp[1210:60b] Unhandled managed exception:
Object reference not set to an instance of an object (System.NullReferenceException)
at Cirrious.CrossCore.Mvx.Resolve[IMvxViewModelLoader] () [0x00006] in <filename unknown>:0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods.LoadViewModel (IMvxTouchView touchView) [0x00057] in <filename unknown>:0
at Cirrious.MvvmCross.Views.MvxViewExtensionMethods.OnViewCreate (IMvxView view, System.Func`1 viewModelLoader) [0x00012] in <filename unknown>:0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerExtensionMethods.OnViewCreate (IMvxTouchView touchView) [0x00001] in <filename unknown>:0
at Cirrious.MvvmCross.Touch.Views.MvxViewControllerAdapter.HandleViewDidLoadCalled (System.Object sender, System.EventArgs e) [0x00007] in <filename unknown>:0
at (wrapper delegate-invoke) <Module>:invoke_void_object_EventArgs (object,System.EventArgs)
at Cirrious.CrossCore.Core.MvxDelegateExtensionMethods.Raise (System.EventH
andler eventHandler, System.Object sender) [0x00004] in <filename unknown>:0
at Cirrious.CrossCore.Touch.Views.MvxEventSourceTableViewController.ViewDidLoad () [0x00006] in <filename unknown>:0
at MyProject.Touch.MostPurchasedView.ViewDidLoad () [0x00048] in d:\Working\Repo\MyApp\<MyProjectName>\MyProject.Touch\Views\OneOfTheView.cs:31
at (wrapper managed-to-native) ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper (intptr,intptr)
at UIKit.UIViewController.get_View () [0x00030] in /Users/builder/data/lanes/2077/d230615b/source/maccore/src/build/ios/native/UIKit/UIViewController.g.cs:2632
at MyProject.Touch.HomeViewController.PrepareForSegue (UIKit.UIStoryboardSegue segue, Foundation.NSObject sender) [0x0016a] in d:\Working\Repo\MyApp\MyProject.Mobile\MyProject.Touch\HomeViewController.cs:335
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at
UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/2077/d230615b/source/maccore/src/UIKit/UIApplication.cs:74
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0001c] in /Users/builder/data/lanes/2077/d230615b/source/maccore/src/UIKit/UIApplication.cs:57
at MyProject.Touch.Application.Main (System.String[] args) [0x00001] in d:\Working\Repo\MyApp\MyProject.Mobile\MyProject.Touch\Main.cs:16
2015-09-21 11:06:26.994 MyApp[1210:60b] critical: Stacktrace:
Native stacktrace:
.....
I tried the above with just calling the below in the View.cs:
public override void ViewDidLoad()
{
try
{
base.ViewDidLoad();
}
catch (Exception ex)
{
// throw a toast msg in the UI
}
}
I disabled all the base.ViewDidLoad() in all the View.cs files in the ViewDidLoad override methods to take it to the next level and the same problem but inside the constructor of MvxSimpleTableViewSource class
Device Log below:
Object reference not set to an instance of an object (System.NullReferenceException)
at Cirrious.CrossCore.Mvx.TryResolve[IMvxTouchSystem] (IMvxTouchSystem& service) [0x00006] in <filename unknown>:0
at Cirrious.CrossCore.Touch.Platform.MvxIosMajorVersionChecker.ReadIsIosVersionOrHigher (Int32 target, Boolean defaultValue) [0x00000] in <filename unknown>:0
at Cirrious.CrossCore.Touch.Platform.MvxIosMajorVersionChecker..ctor (Int32 major, Boolean defaultValue) [0x00006] in <filename unknown>:0
at Cirrious.MvvmCross.Binding.Touch.Views.MvxSimpleTableViewSource..ctor (UIKit.UITableView tableView, System.String nibName, System.String cellIdentifier, Foundation.NSBundle bundle) [0x00000] in <filename unknown>:0
at MyProject.Touch.MostPurchasedView.ViewDidLoad () [0x00059] in d:\Working\Repo\MyApp\MyProject.Mobile\MyProject.Touch\Views\OneOfTheView.cs:42
at (wrapper managed-to-native) ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper (intptr,intptr)
at UIKit.UIViewController.get_View () [0x00030] in /Users/builder/data/lanes/2077/d230615b/source/maccore/src/build/ios/native/UIKit/UIViewController.g.cs:2632
at MyProject.Touch.HomeViewController.PrepareForSegue (UIKit.UIStoryboardSegue segue, Foundation.NSObject sender) [0x0016a] in d:\Working\Repo\MyApp\MyProject.Mobile\MyProject.Touch\HomeViewController.cs:343
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/2077/d230615b/source/maccore/src/UIKit/UIApplication.cs:74
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0001c] in /Users/builder/data/lanes/2077/d230615b/source/maccore/src/UIKit/UIApplication.cs:57
at MyProject.Touch.Application.Main (System.String[] args) [0x00001] in d:\Working\Repo\MyApp\MyProject.Mobile\MyProject.Touch\Main.cs:16
In short :
Only in iOS 9.1, MvvmCross 3.1.1 AND MvvmCross 3.5.1 has a NullReference Issue in line 44 of the MvxViewControllerExtensionMethods class which gets called during ViewDidLoad but works well with iOS 8.4 and below
I am just getting familiar with MvvmCross framework and unsure whether it is an issue with MvvmCross and iOS 9.
Has anyone come across this issue? Any help on this would be appreciated.
Note: The MvvmCross samples work fine with iOS9. So I believe it has to be something with the Tab implementation.

One thing is that MvvmCross 3.1.1 not is build for iOS unified code. This will prevent you from submitting your app. MvvmCross 4.0 is currently in beta, but i would recommend using it, because it has many fixes.
If the code crashes on line 44 while trying to resolve IMvxViewModelLoader, it probably means that you are missing some package where the IMvxViewModelLoader is.

Related

Adding managed DLL to unity3d

I'm trying to implement the $p library to recognize gestures for spell casting in a game but I'm getting a Unhandled Exception. I'm using the precompile dll I got from their website and its compiled in the .Net 4 framework, so I'm guessing this is where the problem is coming from. Here is the error:
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
Missing method .ctor in assembly C:\Users\Uri\Desktop\GestureSpell\GestureSpell\Assets\PDollarGestureRecognizer.dll, type System.Runtime.Versioning.TargetFrameworkAttribute
The class System.Runtime.Versioning.TargetFrameworkAttribute could not be loaded, used in PDollarGestureRecognizer
Can't find custom attr constructor image: C:\Users\Uri\Desktop\GestureSpell\GestureSpell\Assets\PDollarGestureRecognizer.dll mtoken: 0x0a00000d
You can try changing true to false in your .csproj file. That helps in some cases.

App crashes in release mode and not in debug mode - Xamarin Forms

I am building a cross platform app and i want to release it to testers, but it doesn't work when i am deploying it in release mode. As far as exceptions go i do not get any. As stated in the question it works in debug mode. The app just goes to splashscreen and crashes. I ran the original app through test fairy and got this exception:
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
... 2 more
Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.IO.FileNotFoundException: Could not load file or assembly '<Censored: Name of forms class library>.dll' or one of its dependencies. The system cannot find the file specified.
File name: '<Censored: Name of forms class library>.dll'
at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) [0x00000] in :0
at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName)
at System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) [0x00000] in :0
at Xamarin.Forms.Xaml.XamlParser.GetElementType (Xamarin.Forms.Xaml.XmlType xmlType, IXmlLineInfo xmlInfo, System.Reflection.Assembly currentAssembly, Xamarin.Forms.Xaml.XamlParseException& exception) [0x00000] in :0
at (wrapper delegate-invoke) :invoke_Type_XmlType_IXmlLineInfo_Assembly_XamlParseException& (Xamarin.Forms.Xaml.XmlType,System.Xml.IXmlLineInfo,System.Reflection.Assembly,Xamarin.Forms.Xaml.XamlParseException&)
at Xamarin.Forms.Xaml.XamlTypeResolver.Resolve (System.String qualifiedTypeName, IServiceProvider serviceProvider, Xamarin.Forms.Xaml.XamlParseException& exception) [0x00000] in :0
at Xamarin.Forms.Xaml.XamlTypeResolver.TryResolve (System.String qualifiedTypeName, System.Type& type) [0x00000] in :0
at Xamarin.Forms.Xaml.ExpandMarkupsVisitor+MarkupExpansionParser.Parse (System.String match, System.String& remaining, IServiceProvider serviceProvider) [0x00000] in :0
at Xamarin.Forms.Xaml.ExpandMarkupsVisitor.ParseExpression (System.String& expression, IXmlNamespaceResolver nsResolver, IXmlLineInfo xmlLineInfo, INode node, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ExpandMarkupsVisitor.Visit (Xamarin.Forms.Xaml.MarkupNode markupnode, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.MarkupNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.RootNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.String xaml) [0x00000] in :0
at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x00000] in :0
at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[LoginPage] (<Censored>.Login.LoginPage view, System.Type callingType) [0x00000] in :0
at <Censored>.Login.LoginPage.InitializeComponent () [0x00000] in :0
at <Censored>.Login.LoginPage..ctor () [0x00000] in :0
at <Censored>.App.b__0 () [0x00000] in :0
at <Censored>.ViewFactory.Resolve[LoginViewModel] (<Censored>.Login.LoginViewModel viewModel) [0x00000] in :0
at <Censored>.App..ctor () [0x00000] in :0
at md5b406f03a919343acc4f3b337a44e1248.MainActivity.n_onCreate(Native Method)
at md5b406f03a919343acc4f3b337a44e1248.MainActivity.onCreate(MainActivity.java:28)
at android.app.Activity.performCreate(Activity.java:5458)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
at android.app.ActivityThread.access$900(ActivityThread.java:174)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5593)
... 5 more
I cannot show you the source code, but i have reproduced the error in a new test solution.
Here is a link to the repository with the test project. It is just a project using MVVM with Xamarin Forms.
Fixed it by manually deleting all obj folders and all bin folders in the entire solution.
Edit: Came back again and now this fix does not work!
If your solution works in Debug mode, but not in Release mode, it might be an issue with the Linker.
Right Click on your specific project (not Solution) -> Android Options -> Linker -> Choose "None" in Linking. This will include all dlls in the Release Library.

Google Play Games Services can't register class (Unity)

I use GPGS for Unity (this)
When I launch my app on phone i have this (and no activity from plugin):
D/GamesUnitySDK(12145): Performing Android initialization of the GPG SDK
E/GamesNativeSDK(12145): Can't register class com/google/android/gms/nearby/Nearby: an exception occurred.
E/GamesNativeSDK(12145): Can't register class com/google/android/gms/nearby/connection/AppIdentifier: an exception occurred.
E/GamesNativeSDK(12145): Can't register class com/google/android/gms/nearby/connection/AppMetadata: an exception occurred.
E/GamesNativeSDK(12145): Can't register class com/google/android/gms/nearby/connection/Connections: an exception occurred.
E/GamesNativeSDK(12145): Can't register class com/google/android/gms/nearby/connection/Connections$StartAdvertisingResult: an exception occurred.
I/Unity (12145): InvalidOperationException: There was an error creating a GameServices object. Check for log errors from GamesNativeSDK
I/Unity (12145): at GooglePlayGames.Native.PInvoke.GameServicesBuilder.Build (GooglePlayGames.Native.PInvoke.PlatformConfiguration configRef) [0x00000] in <filename unknown>:0
I/Unity (12145): at GooglePlayGames.Native.NativeClient.InitializeGameServices () [0x00000] in <filename unknown>:0
I/Unity (12145): at GooglePlayGames.Native.NativeClient.Authenticate (System.Action 1 callback, Boolean silent) [0x00000] in <filename unknown>:0
I/Unity (12145): at GooglePlayGames.PlayGamesPlatform.Authenticate (System.Action 1 callback, Boolean silent) [0x00000] in <filename unknown>:0
I/Unity (12145): at GooglePlayGames.PlayGamesPlatform.Authenticate (System.Action 1 callback) [0x00000] in <filename unknown>:0
I/Unity (12145): at GooglePlayGames.PlayGamesLocalUser.Authenticate (System.Action`1 callback) [0x00000] in <filename unknown>:0
I/Unity (12145): at GooglePlayServiceController.Login () [0x00000] in <filename unknown>:0
I/Unity (12145): at GooglePlayServiceController.Start () [0x00000] in <filename unknown
For Init use thin in Awake:
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.EnableSavedGames()
.WithInvitationDelegate((invitation, shouldAutoAccept) => {})
.WithMatchDelegate((match, shouldAutoLaunch) => {})
.Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
And this in Start for login:
Social.localUser.Authenticate((bool success) =>
{
});
In google I find some actions to resolve this problem but it doesn't work (last version plugin, last version android sdk, my account is tester in Developer Console).
Someone can help me with this problem?
Happened the same to me and after reading this thread (https://github.com/playgameservices/play-games-plugin-for-unity/issues/506) the solution was:
Update the Android SDK Google Play Services package to a version >=r23 (under the extras category)
Go to Window | Google Play Games | Setup | Android Setup... and click on Setup (this will update the local copy of the library)
Rebuild
Be very careful if you are also using Google Play Games for Unity plugin because you may encounter this problem:
https://github.com/googleanalytics/google-analytics-plugin-for-unity/issues/51

ServiceStackHost.Instance has already been set

I have a bizarre problem.
I have implemented a standard Service Stack API.
It has been working perfect for the last year now.
Last week I saw some major changes to Xamarin Studio so decided to update my IDE.
With that update NuGet comes standard, so I decided to convert my Service Stack Reference Files to use NuGet. Quite nice, now I can update the DLL's etc with 1 click.
So the API works fine on my Windows Machine now, no issues.
Problem: Our servers run Ubuntu with Mono installed. And it does not want to budge.
I Initially get this Error:
System.TypeLoadException: A type load exception has occurred.
at ServiceStack.VirtualPath.FileSystemVirtualPathProvider..ctor (IAppHost appHost, System.IO.DirectoryInfo rootDirInfo) [0x00000] in <filename unknown>:0
at ServiceStack.VirtualPath.FileSystemVirtualPathProvider..ctor (IAppHost appHost, System.String rootDirectoryPath) [0x00000] in <filename unknown>:0
at ServiceStack.ServiceStackHost.Init () [0x00000] in <filename unknown>:0
at API_NOTIFICATION.Global.Application_Start (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
Then I refresh the page and I keep getting this error:
System.IO.InvalidDataException: ServiceStackHost.Instance has already been set
at ServiceStack.ServiceStackHost.Init () [0x00000] in <filename unknown>:0
at API_NOTIFICATION.Global.Application_Start (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
Anyone Experienced this before? Anyone know how to fix this?
I did look at other posts similar to this one.
No idea where to find:
App_Start/ServiceStackFramework.cs
And no idea how to remove as again I cant find that anywhere. But who knows, it might not even be the same problem at all.
I have used the standard Tutorial to set up the API which is posted on the ServiceStack Website.
Any help will be much appreciated. And like I said, the only think that really changed is the IDE and updating those ServiceStack references via NuGet.
AppHost:
public class ResponseNotificationServiceAppHost : AppHostBase
{
public ResponseNotificationServiceAppHost() : base("Response Notification Services", typeof(NotificationServices).Assembly)
{
}
#region implemented abstract members of AppHostBase
public override void Configure(Funq.Container container)
{
}
#endregion
}
Global:
public class Global : System.Web.HttpApplication
{
protected void Application_Start(Object sender, EventArgs e)
{
new ResponseNotificationServiceAppHost().Init();
}
}
API Service Class:
public class NotificationServices : Service
{
public PersonNotificationResponse Any(PersonNotification request)
{
// Implementation Code here
}
}
Update:
When trying to remove the AppHost, the API would not load. I get the following error on the Ubuntu Server:
System.NullReferenceException: Object reference not set to an instance of an object
at ServiceStack.HttpHandlerFactory..cctor () [0x00000] in <filename unknown>:0
Looks like it was a problem with the mono framework.
The server was running on 2.10.5 Mono on a 12.04 LTS server.
I hosted the API on a new 14.04 LST server with Mono 3.2.6 installed.
Works fine now.
Maybe ServiceStack was updated which was not compatible with 2.10.5 anymore. Not sure, can only speculate.

System.Collections.Generic.KeyNotFoundException with Mono, but not Microsoft's .NET

I found a really strange problem while creating unit tests that only occurs with the Mono runtime (Xamarin on Mac included), but runs fine within Visual Studio. I isolated it as far as I could, and I reached a point that I can't tell if it is a bug with Mono, Moq or Castle DinamicProxy, although it only crashes when using the Mono runtime.
This is the code:
using System;
using System.Collections.Generic;
using Moq;
namespace ConsoleApplication1
{
public interface ISomething<T>
{
List<T> DoSomething<U>(/*Func<T, U> expression*/);
}
public class Foo { }
public class Program
{
public static void Main(string[] args) {
var mock = new Mock<ISomething<Foo>>();
Console.WriteLine(mock.Object);
}
}
}
Here's that I know:
It compiles and run with within Visual Studio 2012. The output is "Castle.Proxies.ISomething`1Proxy"
It does not work when running with the Mono runtime. An exception is thrown (see below)
If I change the declaration from an interface to an abstract class, it works with Mono
If I change the return type from List<T> to anything else, it works with Mono
If I remove the generic type <U>, it works with mono
Got the same results under Windows, Mac and Linux using the command line build from http://mono-project.com
In Windows it fails with Mono 2.10.9, but works within Xamarin.Studio (4.0.10)
In Mac, it fails within Xamarin.Studio (4.0.10)
I recompiled Moq linking agains the latest DynamicProxy release (Castle.Core.3.2.0), with no changed to the behaviour.
Although I've found this problem when using Moq, but I can't tell if it's related to it or even DynamicProxy. The partial exception is below, complete can be found at http://pastie.org/8203093
mono ConsoleApplication1.exe
[ERROR] FATAL UNHANDLED EXCEPTION: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2[System.String,System.Reflection.Emit.GenericTypeParameterBuilder].get_Item (System.String key) [0x00000] in <filename unknown>:0
at Castle.DynamicProxy.Internal.TypeUtil.CloseGenericParametersIfAny (Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter emitter, System.Type[] arguments) [0x00000] in <filename unknown>:0
at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget (System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.IInterceptor[] interceptors) [0x00000] in <filename unknown>:0
at Moq.Proxy.CastleProxyFactory.CreateProxy[ISomething`1] (ICallInterceptor interceptor, System.Type[] interfaces, System.Object[] arguments) [0x00000] in <filename unknown>:0
[....]
at Moq.Mock`1[ConsoleApplication1.ISomething`1[ConsoleApplication1.Foo]].<InitializeInstance>b__0 () [0x00000] in <filename unknown>:0
at Moq.PexProtector.Invoke (System.Action action) [0x00000] in <filename unknown>:0
at Moq.Mock`1[ConsoleApplication1.ISomething`1[ConsoleApplication1.Foo]].InitializeInstance () [0x00000] in <filename unknown>:0
at Moq.Mock`1[ConsoleApplication1.ISomething`1[ConsoleApplication1.Foo]].OnGetObject () [0x00000] in <filename unknown>:0
at Moq.Mock.GetObject () [0x00000] in <filename unknown>:0
at Moq.Mock.get_Object () [0x00000] in <filename unknown>:0
at Moq.Mock`1[ConsoleApplication1.ISomething`1[ConsoleApplication1.Foo]].get_Object () [0x00000] in <filename unknown>:0
at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

Categories

Resources