Accessing Resources for the First Time in Xamarin.Android is Slow - xamarin

I am creating an application that will target the Android OS using Xamarin (currently Xamarin.Forms but could also be Xamarin.Android). This application will access core business functionality via web API calls.
I have noticed that each time I run the application, the first time I perform an API call it is much slower than it is when making subsequent calls. For the hardware I am targeting, the first calls usually takes somewhere around 3000ms while subsequent calls are somewhere between 200ms and 300ms. This behavior is consistent each time I restart the application.
In trying to isolate where the issue originates, I have tested the API endpoint using Fiddler and the response times are always very fast. I also created a UWP project to see if it was specific to Android or anything Xamarin targets. It looks like this issue is specific to Android.
When the first API call is made, output in the debug window similar to the following is generated:
07-28 00:03:50.354 D/Mono (15670): DllImport searching in: '__Internal' ('(null)').
07-28 00:03:50.354 D/Mono (15670): Searching for 'java_interop_jnienv_call_float_method_a'.
07-28 00:03:50.354 D/Mono (15670): Probing 'java_interop_jnienv_call_float_method_a'.
07-28 00:03:50.354 D/Mono (15670): Found as 'java_interop_jnienv_call_float_method_a'.
07-28 00:03:50.564 D/Mono (15670): Loading reference 8 of netstandard.dll asmctx DEFAULT, looking for System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
07-28 00:03:50.564 D/Mono (15670): Image addref System.Net.Http[0x65db9f70] (asmctx DEFAULT) -> System.Net.Http.dll[0x65dc4118]: 2
07-28 00:03:50.564 D/Mono (15670): Prepared to set up assembly 'System.Net.Http' (System.Net.Http.dll)
07-28 00:03:50.564 D/Mono (15670): Assembly System.Net.Http[0x65db9f70] added to domain RootDomain, ref_count=1
07-28 00:03:50.564 D/Mono (15670): AOT: image 'System.Net.Http.dll.so' not found: (null)
07-28 00:03:50.574 D/Mono (15670): AOT: image '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-armeabi-v7a-release/lib/mono/aot-cache/arm/System.Net.Http.dll.so' not found: (null)
07-28 00:03:50.574 D/Mono (15670): Config attempting to parse: 'System.Net.Http.dll.config'.
07-28 00:03:50.574 D/Mono (15670): Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-armeabi-v7a-release/etc/mono/assemblies/System.Net.Http/System.Net.Http.config'.
07-28 00:03:50.574 D/Mono (15670): Assembly Ref addref netstandard[0x64a97cd0] -> System.Net.Http[0x65db9f70]: 2
07-28 00:03:50.574 D/Mono (15670): Loading reference 0 of System.Net.Http.dll asmctx DEFAULT, looking for mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
07-28 00:03:50.574 D/Mono (15670): Assembly Ref addref System.Net.Http[0x65db9f70] -> mscorlib[0x62b37138]: 33
Loaded assembly: System.Net.Http.dll [External]
07-28 00:03:50.584 D/Mono (15670): Loading reference 1 of System.Net.Http.dll asmctx DEFAULT, looking for System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
07-28 00:03:50.584 D/Mono (15670): Assembly Ref addref System.Net.Http[0x65db9f70] -> System[0x645da088]: 6
Thread started: #2
07-28 00:03:50.844 D/Mono (15670): Loading reference 2 of System.Net.Http.dll asmctx DEFAULT, looking for System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
07-28 00:03:50.844 D/Mono (15670): Assembly Ref addref System.Net.Http[0x65db9f70] -> System.Core[0x6488b0c0]: 6
Thread started: <Thread Pool> #3
Thread started: <Thread Pool> #4
Thread started: <Thread Pool> #5
Thread started: <Thread Pool> #6
Thread started: <Thread Pool> #7
Thread started: <Thread Pool> #8
07-28 00:03:51.265 D/Mono (15670): DllImport attempting to load: 'libmono-native.so'.
07-28 00:03:51.275 D/Mono (15670): DllImport loaded library './libmono-native.so'.
07-28 00:03:51.275 D/Mono (15670): DllImport searching in: 'libmono-native.so' ('./libmono-native.so').
07-28 00:03:51.275 D/Mono (15670): Searching for 'SystemNative_GetNonCryptographicallySecureRandomBytes'.
07-28 00:03:51.275 D/Mono (15670): Probing 'SystemNative_GetNonCryptographicallySecureRandomBytes'.
07-28 00:03:51.275 D/Mono (15670): Found as 'SystemNative_GetNonCryptographicallySecureRandomBytes'.
Thread started: <Thread Pool> #9
On subsequent API calls, nothing is generated in the debug window (which more or less explains why the response times are quicker).
Can someone explain what is happening here? Is there a way around this (say, to load resources up from on application start)? Is there a better way?
I don't think the code that calls the API is the issue (as the UWP version does not exhibit the described behavior) but I have included this code below just in case.
var uri = new Uri("...");
try
{
var stopwatch = new Stopwatch();
stopwatch.Start();
using (var client = new HttpClient())
{
using (var response = await client.GetAsync(uri))
{
}
}
stopwatch.Stop();
ResponseTimeLabel.Text = $"{stopwatch.ElapsedMilliseconds.ToString()}ms";
}
catch (Exception exception)
{
ResponseTimeLabel.Text = $"Exception: {exception.Message}";
}

I search some info, and I guess that there are many reason for this.
The app pool is warming up, routes are being built, DI containers may be registering object graphs, caching is occurring, execution plans are being generated and cached, etc etc etc.
there are also other concerns such as JIT overhead and DNS lookups.
You should always assume application warmup time will be required. It is considered best practice to warm up the application on first run to ensure quick responses for consumers of your application. You can't avoid this warmup cost, nor should you try to do so. Rather, structure your deployments so that you are able to warm up the application before users hit it, such as proper load balancing and server rotation.

Related

Xamarin Android MvvmCross Linking issues

I am building my first release version of Xamarin Android with MvvmCross. Just like most other people who have similar issue, the app run ok in debug mode but not release with linking. I have been stuck and searched for days but still could not resolve it. Please kindly help.
I have the latest Visual Studio 2017 v15.7.2, .net 4.7.03056, Xamarin 4.10.0.48 & Android SDK 8.1 installed.
To resolve the issue, I start running in Debug mode with linking “Sdk Assemblies Only” and not using Shared Runtime. The following errors occur:
05-24 02:21:52.490 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.dll'.
05-24 02:21:52.490 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/System.Runtime.dll'.
05-24 02:21:52.490 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.exe'.
05-24 02:21:52.491 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/System.Runtime.exe'.
05-24 02:21:52.491 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.dll'.
05-24 02:21:52.491 D/Mono( 9114) : Assembly Loader probing location: '/storage/emulated/0/Android/data/.../files/.__override__/System.Runtime.dll'.
05-24 02:21:52.491 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/System.Runtime.dll'.
05-24 02:21:52.491 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.exe'.
05-24 02:21:52.491 D/Mono( 9114) : Assembly Loader probing location: '/storage/emulated/0/Android/data/xxx.Droid/files/.__override__/System.Runtime.exe'.
05-24 02:21:52.493 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/System.Runtime.exe'.
05-24 02:21:52.493 W/Mono( 9114) : The following assembly referenced from /storage/emulated/0/Android/data/xxx.Droid/files/.__override__/MvvmCross.Platform.dll could not be loaded:
05-24 02:21:52.493 W/Mono( 9114) : Assembly: System.Runtime(assemblyref_index=0)
05-24 02:21:52.493 W/Mono( 9114) : Version: 4.0.0.0
05-24 02:21:52.493 W/Mono( 9114) : Public Key: b03f5f7f11d50a3a
05-24 02:21:52.493 W/Mono( 9114) : The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly(/storage/emulated/0/Android/data/xxx.Droid/files/.__override__/).
05-24 02:21:52.493 D/Mono( 9114) : Failed to load assembly MvvmCross.Platform[0xe7ec5ea0].
05-24 02:21:52.493 W/ ( 9114): Could not load signature of MvvmCross.Platform.Droid.Views.MvxEventSourceActivity:add_CreateWillBeCalled due to: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.assembly:System.Runtime, Version= 4.0.0.0, Culture= neutral, PublicKeyToken= b03f5f7f11d50a3a type:<unknown type> member:(null) signature:<none>
Unhandled Exception:
System.TypeLoadException: Could not resolve the signature of a virtual method
05-24 02:24:36.309 D/Mono( 9114) : Assembly Ref addref xxx.Droid[0xe7ec5240] -> MvvmCross.Plugins.ResxLocalization[0xe7ec6260]: 2
05-24 02:24:36.310 D/Mono ( 9114): Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.dll'.
05-24 02:24:36.310 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/System.Runtime.dll'.
05-24 02:24:36.310 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.exe'.
05-24 02:24:36.310 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/System.Runtime.exe'.
05-24 02:24:36.311 D/Mono( 9114) : Assembly Loader probing location: '/usr/local/lib/mono/gac/System.Runtime/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.dll'.
05-24 02:24:36.311 D/Mono( 9114) : Assembly Loader probing location: '/storage/emulated/0/Android/data/xxx.Droid/files/.__override__/System.Runtime.dll'.
It seems that it is trying to locate an older version of System.Runtime. I added bindingRedirect to the app.conig. No luck with it: Removing all dependentAssembly does not help too. My System.Runtime version is 4.3.0
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.2.0" newVersion="1.2.2.0" />
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
When running in Release mode with “Sdk Assemblies Only”, I got the following message in log (sorry for not able to copy it as text but screen shot only):
This looks more like related to linking. I have the standard LinkerPleaseInclude with all property & method that were bound in my xml specified. However, the app crash at the splash screen before reaching my own code. This is the code of my splashscreen, just the untouched one clone from the sample.
namespace xxx.Droid
{
[Activity(
Label = "xxx.Droid"
, MainLauncher = true
, Icon = "#drawable/icon"
, Theme = "#style/Theme.Splash"
, NoHistory = true
, ScreenOrientation = ScreenOrientation.Portrait)]
public class SplashScreen : MvxSplashScreenActivity
{
public SplashScreen()
: base(Resource.Layout.splash_screen)
{
}
}
}
In summary,
I have 3 questions right now:
BindingRedirect in debug mode does not work. Cannot run with linking in debug mode made problem solving much harder
In release mode, crash at splash screen. However, I cannot see what is missing from the log
Is there any rule / hint from log to find out what should be included in the linkerpleaseinclude?
Thank you very much for any help
Nick

Missing assemblies after migrating Silverlight 4 application to visual studio 2013 Silverlight 5

We are migrating a Silverlight4 application developed in visual studio 2010 with active directory single sign on to Silverlight 5 for visual studio 2013.
After replacing some .dll's like toolkit and data visualization toolkit and other dll without changing the framework(4.0) it was working fine but When I am changing the active directory project framework from 3.5 to 4.0 or higher it is throwing the following errors:
Error 71 The type name 'RoleProvider' could not be found. This type has been forwarded to assembly 'System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly.
Error 73 The type name 'MembershipUser' could not be found. This type has been forwarded to assembly 'System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly.
Error 74 The type name 'MembershipUser' could not be found. This type has been forwarded to assembly 'System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly.
Error 75 The type name 'MembershipUser' could not be found. This type has been forwarded to assembly 'System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly.
Error 76 The type name 'MembershipUser' could not be found. This type has been forwarded to assembly 'System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly.
Error 78 The type name 'MembershipUser' could not be found. This type has been forwarded to assembly 'System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly.
Error 77 The type name 'MembershipCreateStatus' could not be found. This type has been forwarded to assembly 'System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider adding a reference to that assembly.
Error 72 The type 'System.Web.Security.MembershipProvider' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
I tried replacing the assemblies and namespaces but no luck. Does anyone came across this kind of issues. I would appreciate your help if you could give me a solution. thank you very much
remove the existing reference to System.Web.ApplicationServices.dll and refer System.Web.ApplicationServices with version 4.0.0.0.. or higher
You can find it in a folder that might look like C:\Windows\Microsoft.NET\Framework64\v4.0.30319

MVVMCross: View (Android layout) doesn't load

I tried to use the MVVMCross following the TipCalc example but my View doesn't load. I can see the Activity label but the layout doesn't show up, with the following application output:
Forwarding debugger port 8973
Forwarding console port 8974
Detecting existing process
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/MVX.DroidWUL.dll
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/Cirrious.MvvmCross.Droid.dll [External]
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/Cirrious.CrossCore.Droid.dll [External]
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/Cirrious.CrossCore.dll [External]
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/System.Windows.dll [External]
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/Cirrious.MvvmCross.dll [External]
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/Cirrious.MvvmCross.Binding.dll [External]
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/Cirrious.MvvmCross.Binding.Droid.dll [External]
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/PCLCoreMVX.dll
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/Cirrious.MvvmCross.Plugins.Json.dll [External]
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/Newtonsoft.Json.dll [External]
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/System.Net.dll [External]
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/System.Xml.Serialization.dll [External]
Loaded assembly: /data/data/MVX.DroidWUL/files/.__override__/Cirrious.MvvmCross.Localization.dll [External]
Loaded assembly: Mono.Android.dll [External]
Loaded assembly: System.Core.dll [External]
[ApplicationPackageManager] cscCountry is not German : LUX
[mono] WARNING: The runtime version supported by this application is unavailable.
[mono] Using default runtime: v2.0.50727
[monodroid-gc] GREF GC Threshold: 46800
[MonoDroid] Xamarin/Android Trial Mode Active
[ApplicationPackageManager] cscCountry is not German : LUX
Loaded assembly: MonoDroidConstructors [External]
[ApplicationPackageManager] cscCountry is not German : LUX
Loaded assembly: System.dll [External]
Loaded assembly: System.Xml.dll [External]
[mvx] 0.05 Setup: PlatformServices start
mvx:Diagnostic: 0.05 Setup: PlatformServices start
[mvx] 0.70 Setup: Bootstrap actions
mvx:Diagnostic: 0.70 Setup: Bootstrap actions
[mvx] 0.82 Setup: StringToTypeParser start
mvx:Diagnostic: 0.82 Setup: StringToTypeParser start
[mvx] 0.84 Setup: ViewModelFramework start
mvx:Diagnostic: 0.84 Setup: ViewModelFramework start
[mvx] 0.85 Setup: PluginManagerFramework start
mvx:Diagnostic: 0.85 Setup: PluginManagerFramework start
[mvx] 0.89 Configuring Plugin Loader for Cirrious.MvvmCross.Plugins.Json.PluginLoader
mvx:Diagnostic: 0.89 Configuring Plugin Loader for Cirrious.MvvmCross.Plugins.Json.PluginLoader
[mvx] 0.89 Ensuring Plugin is loaded for Cirrious.MvvmCross.Plugins.Json.PluginLoader
mvx:Diagnostic: 0.89 Ensuring Plugin is loaded for Cirrious.MvvmCross.Plugins.Json.PluginLoader
[mvx] 0.90 Setup: App start
mvx:Diagnostic: 0.90 Setup: App start
[mvx] 0.91 Setup: ViewModelTypeFinder start
mvx:Diagnostic: 0.91 Setup: ViewModelTypeFinder start
[mvx] 0.92 Setup: ViewsContainer start
mvx:Diagnostic: 0.92 Setup: ViewsContainer start
[mvx] 0.93 Setup: ViewDispatcher start
mvx:Diagnostic: 0.93 Setup: ViewDispatcher start
[mvx] 0.95 Setup: Views start
mvx:Diagnostic: 0.95 Setup: Views start
[mvx] 1.15 Setup: CommandCollectionBuilder start
mvx:Diagnostic: 1.15 Setup: CommandCollectionBuilder start
[mvx] 1.16 Setup: NavigationSerializer start
mvx:Diagnostic: 1.16 Setup: NavigationSerializer start
[mvx] 1.21 Setup: LastChance start
mvx:Diagnostic: 1.21 Setup: LastChance start
[mvx] 1.53 Setup: Secondary end
mvx:Diagnostic: 1.53 Setup: Secondary end
[mvx] 1.62 Null Extras seen on Intent when creating ViewModel - this should not happen - have you tried to navigate to an MvvmCross View directly?
mvx:Error: 1.62 Null Extras seen on Intent when creating ViewModel - this should not happen - have you tried to navigate to an MvvmCross View directly?
[mvx] 1.63 ViewModel not loaded for view CalenderWUL
mvx:Warning: 1.63 ViewModel not loaded for view CalenderWUL
What am i doing wrong?
Thanks
What am I doing wrong?
From that level of detail, no idea
The problem is clearly somewhere in the initialisation of CalendarWUL - whatever that is. But I can't diagnose it from that.
Some things you could try:
does the completed sample (using a more up to date version of the code) run from: https://github.com/slodge/MvvmCross-Tutorials/tree/master/TipCalc
do the latest released binaries work - https://github.com/slodge/MvvmCross-Binaries/
or do older versions work (from that same folder)
does the complete video walkthrough help - https://www.youtube.com/watch?v=qGup08cz7LM&list=PLR6WI6W1JdeYSXLbm58jwAKYT7RQR31-W (there are several other walkthroughs on that same playlist)

get invalid exception

System.InvalidOperationException was unhandled
Message=An error occurred creating the form. See Exception.InnerException for details. The error is: Could not load file or assembly 'Interop.WMPLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source=kn diary
StackTrace:
at kn_diary.My.MyProject.MyForms.Create_Instance_[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
at kn_diary.My.MyProject.MyForms.get_Form1()
at kn_diary.My.MyApplication.OnCreateMainForm() in C:\Users\Pak\Desktop\project\kn diary\kn diary\My Project\Application.Designer.vb:line 35
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at kn_diary.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.BadImageFormatException
Message=Could not load file or assembly 'Interop.WMPLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source=AxInterop.WMPLib
FileName=Interop.WMPLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
FusionLog==== Pre-bind state information ===
LOG: User = Pak-PC\Pak
LOG: DisplayName = Interop.WMPLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Users/Pak/Desktop/project/kn diary/kn diary/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : AxInterop.WMPLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Pak\Desktop\project\kn diary\kn diary\bin\Debug\kn diary.vshost.exe.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/Pak/Desktop/project/kn diary/kn diary/bin/Debug/Interop.WMPLib.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
StackTrace:
at AxWMPLib.AxWindowsMediaPlayer.AttachInterfaces()
at System.Windows.Forms.AxHost.GetOcxCreate()
at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
at System.Windows.Forms.AxHost.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.AxHost.EndInit()
at kn_diary.Form1.InitializeComponent() in C:\Users\Pak\Desktop\project\kn diary\kn diary\Form1.designer.vb:line 91
at kn_diary.Form1..ctor()
InnerException:
This is an indication of failure to load one of the reference assemblies in the chain of references, in this case, an indirect reference. I normally check the fusion log to find out exactly what assembly is failing to load and often why.
Can you check the fusion log and paste the log here in case if you do not already spot the culprit there? You can lunch logger by running "fuslogvw.exe" from VS command prompt. (this link has more detail on how to use the fusion log viewer: http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.80).aspx)

Assembly Binding Old Reference Exception

I have been trying to solve an assembly binding issue for the last 12 hours, with not much luck. Last week, I had upgraded all of the projects in a solution from EF 4.1.0.0 to EF 4.3.1.0. I added some tests this morning to an existing test project, cleaned and recompiled the solution. All the projects compile with no warnings or errors. At my entity framework call anywhere in the project, I receive the following exception:
Initialization method
NutricityPPCTests.Common.DizzleProductExtensionsTests.TestSetup threw
exception. System.IO.FileLoadException: System.IO.FileLoadException:
Could not load file or assembly 'EntityFramework, Version=4.1.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040).
I fired up the fusion assembly binding log viewer, and found the log entry that corresponds to the exception. I have verified that my test project, the MOMData project both are referencing the correct EF4.3.1.0 assembly. I verified there were no references to EF 4.1.0.0 in the project files. I deleted the contents of the obj and bin directories in both projects. The project has been cleaned and rebuilt so many times, that my hard drive is probably going to give out tomorrow.
*** Assembly Binder Log Entry (3/22/2012 # 5:55:11 PM) ***
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\QTAgent32.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = NUTRICITY0\awolske
LOG: DisplayName = EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
(Fully-specified)
LOG: Appbase = file:///C:/Users/awolske/Documents/NutricityWorkspace/Nutricity/NutricityPPCTests/bin/Release
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = QTAgent32.exe
Calling assembly : MomData, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\awolske\Documents\NutricityWorkspace\Nutricity\NutricityPPCTests\bin\Release\NutricityPPCTests.DLL.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Users/awolske/Documents/NutricityWorkspace/Nutricity/NutricityPPCTests/bin/Release/EntityFramework.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Users\awolske\Documents\NutricityWorkspace\Nutricity\NutricityPPCTests\bin\Release\EntityFramework.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Where else should I be looking for the old referenced assembly?!? Any help would be welcome, and greatly appreciated! Thanks in advance for your time!
Add the following to your web.config file:
<runtime>
<assemblyBinding>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
I had the same error. Most of the projects in my solution where referencing the Entity Framework 4.3.0.0 dll, but when I checked the references for all the projects in my solution, I found some projects referencing the Entity Framework 4.1.0.0 dll. Removing and replacing them with new references to the Entity Framework 4.3.0.0 dll fixed the problem.

Resources