Problems executing the same piece of code on VS 2015 and VS 2013

When I run the code snippet in Visual Studio 2013 and 2015, I get two different results. On Visual Studio 2015, I get NullReference, and in 2013, it works as it should. Visual Studio 2015 also runs on Windows 10 and 2013 on Windows 8.1. Piece of code:

private static T FindParentOfType<T>(DependencyObject o)
{
    dynamic parent = VisualTreeHelper.GetParent(o);
    return parent.GetType().IsAssignableFrom(typeof(T)) ? parent : FindParentOfType<T>(parent);
}

The code is called using:

Grid RiskGrid = FindParentOfType<Grid>(ChampViewModelSel);

Error checking IsAssginableFromat the check IsAssginableFrombecause she finds Canvas VS2015 instead of the desired mesh, which is in VS2013?

Stack trace

  StackTrace  "   at Microsoft.CSharp.RuntimeBinder.SymbolTable.GetOriginalTypeParameterType(Type t)\r\n   
    at Microsoft.CSharp.RuntimeBinder.SymbolTable.AreTypeParametersEquivalent(Type t1, Type t2)\r\n   
    at Microsoft.CSharp.RuntimeBinder.SymbolTable.LoadMethodTypeParameter(MethodSymbol parent, Type t)\r\n   
    at Microsoft.CSharp.RuntimeBinder.SymbolTable.LoadSymbolsFromType(Type originalType)\r\n   
    at Microsoft.CSharp.RuntimeBinder.SymbolTable.AddMethodToSymbolTable(MemberInfo member, AggregateSymbol callingAggregate, MethodKindEnum kind)\r\n   
    at Microsoft.CSharp.RuntimeBinder.SymbolTable.AddNamesInInheritanceHierarchy(String name, BindingFlags flags, List 1 inheritance)\r\n   
    at Microsoft.CSharp.RuntimeBinder.SymbolTable.PopulateSymbolTableWithName(String name, IEnumerable 1 typeArguments, Type callingType)\r\n   
    at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.PopulateSymbolTableWithPayloadInformation(DynamicMetaObjectBinder payload, Type callingType, ArgumentObject[] arguments)\r\n  
    at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.BindCore(DynamicMetaObjectBinder payload, IEnumerable 1 parameters, DynamicMetaObject[] args, DynamicMetaObject& deferredBinding)\r\n
    at Microsoft.CSharp.RuntimeBinder.RuntimeBinder.Bind(DynamicMetaObjectBinder payload, IEnumerable 1 parameters, DynamicMetaObject[] args, DynamicMetaObject& deferredBinding)\r\n 
    at Microsoft.CSharp.RuntimeBinder.BinderHelper.Bind(DynamicMetaObjectBinder action, RuntimeBinder binder, IEnumerable 1 args, IEnumerable 1 arginfos, DynamicMetaObject onBindingError)\r\n 
    at Microsoft.CSharp.RuntimeBinder.CSharpInvokeMemberBinder.FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)\r\n
    at System.Dynamic.DynamicMetaObject.BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)\r\n 
    at System.Dynamic.InvokeMemberBinder.Bind(DynamicMetaObject target, DynamicMetaObject[] args)\r\n
    at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection 1 parameters, LabelTarget returnLabel)\r\n
    at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite 1 site, Object[] args)\r\n 
    at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)\r\n
    at BC_Game.ViewModel.ChampionViewModel.FindParentOfType[T](DependencyObject o)\r\n 
    at BC_Game.ViewModel.ChampionViewModel.ManStart(ManipulationStartedEventArgs e)"    string

Update

VS2013 is installed on Win10, and the problem persists. VS2013 works fine on Win8.1

Update

From Visual Studio 2013 wp 8.1

C:\Program Files (x86)\MSBuild\12.0\bin\Csc.exe/noconfig/nowarn: 1701,1702,2008/nostdlib +/errorreport: prompt/warn: 4/define: DEBUG; TRACE/errorendlocation/preferreduilang: en-US/reference: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\mscorlib.dll" /: "C:\Program Files (x86) )\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\\158\Microsoft.CSharp.dll" /: "C:\Program Files (x86)\ \Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\mscorlib.dll" /: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\System.Core.dll" /: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\System.dll" /: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\\158\System.Net.dll" /: "C:\Program Files (x86)\Reference Asse mblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\System.Runtime.Serialization.dll" /reference: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\\158\System.ServiceModel.dll" /: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\\158\System.ServiceModel.Web.dll" /: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\System.Windows.dll" /: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\System.Xml.dll" /: "C:\Program Files (x86)\ \Microsoft\Framework.NETPortable\v4.0\\158\System.Xml.Linq.dll" /reference: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\System.Xml.Serialization.dll" /debug +/debug: full/filealign: 512/optimize-/out:obj\Debug\LibraryOfModels.dll/target: l library/utf8output BuyMenuClass.cs CastleModel.cs ChampionModel.cs ChatDTO.cs CollectionCombiner.cs Country.cs CurrentUser.cs DecorationListItems.cs GameDTO.cs MapTransform.cs MarketplaceModel.cs MenuFirstPageModel.cs NotifyBase.cs Player.cs PopupColorPickerModel.cs PopupExtraInfoModel. cs PopUpModel.cs \AssemblyInfo.cs RankingDTO.cs RankingModel.cs ShieldGearModel.cs UnitModel.cs UserDTO.cs WarCalculations.cs "C:\Users\Jonas\AppData\Local\Temp.NETPortable, Version = v4.0, = Profile158.AssemblyAttributes.cs"

VS 2015 Win 10

C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe/noconfig/nowarn: 1701,1702,2008/nostdlib +/errorreport: prompt/warn: 4/define: DEBUG; TRACE/errorendlocation/preferreduilang: en-US/reference: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\mscorlib.dll" /: "C:\Program Files (x86) )\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\\158\Microsoft.CSharp.dll" /: "C:\Program Files (x86)\ \Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\mscorlib.dll" /: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\System.Core.dll" /: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\System.dll" /: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\\158\System.Net.dll" /: "C:\Program Files (x86)\Reference Asse mblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\System.Runtime.Serialization.dll" /reference: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\\158\System.ServiceModel.dll" /: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\\158\System.ServiceModel.Web.dll" /: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\System.Windows.dll" /: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\System.Xml.dll" /: "C:\Program Files (x86)\ \Microsoft\Framework.NETPortable\v4.0\\158\System.Xml.Linq.dll" /reference: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158\System.Xml.Serialization.dll" /debug +/debug: full/filealign: 512/optimize-/out:obj\Debug\LibraryOfModels.dll/ruleset: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\ \ \MinimumRecommendedRules.ruleset" /target: library/utf8output BuyMenuClass.cs CastleModel.cs ChampionModel.cs ChatDTO.cs CollectionCombiner.cs Country.cs CurrentUser.cs DecorationListItems.cs GameDTO.cs MapTransform.cs MarketplaceModel.cs MenuFirstPageModel.cs NotifyBase.cs Player.cs PopupColorPickerModel.cs PopupExtraInfoModel.cs PopUpModel.cs \AssemblyInfo.cs RankingDTO.cs RankingModel.cs ShieldGearModel.cs UnitModel.cs UserDTO.cs WarCalculations.cs "C:\Users\johann\AppData\Local\Temp.NETPortable, Version = v4.0, Profile = Profile158.AssemblyAttributes.cs"

, , - .NetFrameworks. 4.5.51650, - 4.6.01038.

, win 10 .

+4
2

, . VS2013 VS2015, .NET, .

, ,

VisualTreeHelper.GetParent(o);

, , .

, .

google, VisualTreeHelper.GetParent null

VisualTreeHelper.GetParent null

0

All Articles