jet-image-loader
jet-image-loader copied to clipboard
Resharper warning "Unable to determine application identity of the caller" in app.xaml.
Do you have this issue?
http://clip2net.com/clip/m0/1383941405-clip-5kb.png
Probably, we would need to have some kind of isostorage protection against designtime access.
mm, what did you mean with "some kind of isostorage protection agains designtime access"?
I googled some time ago about that "Unable to determine application identity of the caller", and it was said that it appears when designtime (particulary in convertors) tries to access to isoStorage.
it should be kinda
object Convert(blahblah)
{
if (IsDesignTime)
return "designtime text";
IsoStorage.ReadFile("Whatewer.txt");
}
PS: however, i'm still having that warning in some cases, when isostorage is not used - that's the second reason why i asked you :)
PPS: formatting is crapy here
Anyway, so do you also see that resharper warning in your case?
Yes, I see it too. I'll check it now
Can you check this solution, I don't have Resharper on home laptop
in BaseJetImageLoader.cs
public virtual object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (System.ComponentModel.DesignerProperties.IsInDesignTool)
{
// hack to hide warning "Unable to determine application identity of the caller" in XAML editor
// no sideeffects in runtime on WP
return null;
}
// method body
}
Yep, that's protection i mentioned :) However, i see the same warning in some other lines - that's why i asked you if you are familiar with it,
Meanwhile, i'm solving another problem (maybe offtop a bit, but i dont want to spawn tons of threads).
Somehow, it works fine in test project, but in real project it crashes with exception "The type 'MyAppJetImageLoaderConverter' was not found." Re-checking everything again and again, cant see a cause of the problem.
If to make a dummy converter, which inherits IValueConverter, it works fine. But once i'm inheriting BaseJetImageLoaderConverter (which is also inherited from IValueConverter), it crashes. When i'll find the cause of problem, i'll add it to readme or to another file like FAQ/BestPractises.
Hmm, strange behavior. I am using JetImageLoader in two apps and never had that error.
May be this will help you? (the type or namespace name could not be found)[http://stackoverflow.com/questions/4764978/the-type-or-namespace-name-could-not-be-found]
In most of answers solution is to check .NET version of referenced projects and if they differs, you should set same versions for them.
Nope, wp versions doesnt have lots of .net versions. Only "target WP 7.1" or "target WP8".
Some freaking magic is going on... I rebuilded everything, also added *.pdb file.
-
At first, it crashed at Interlocked.Add with "NotSupportedException", however no compiletime erorrs (found this http://stackoverflow.com/questions/10451176/interlocked-read-and-long-overloads-supported-in-the-portable-class-libraries)
-
Now i rebuilded everything and i'm getting "IsoStorage access" Exception at
_lastAccessTimeDictionary.Add(fullCacheFilePath, ISF.GetLastAccessTime(cacheFileName).Millisecond);
Probably i should go to sleep :)
Ok, looking like i'm using different Bcl versions. However, i see no updates notifications.
Weird thing is that with autoinstall, i got version 1.0.19 (for wp7 version of your lib), but my project (which throws exceptions) is using 1.1.3.
Just great.
Reinstalling of Bcl and dependent packages hepled. Now i'm able to run JetCacher in my real app. Proceeding to testing leaks as mentioned before.
If to talk about subj (DesignerProperties.IsInDesignTool), it didnt help.
At first, i thought that Release build just "optimize" and throw away that condition. However, JustDecompile shows that it is still there. And yes, "Unable to determine application identity of the caller" warning is still there.
Holy crap.. it works on Lumia 920, but it fails on Lumia 800 (interlocked exception). Thats weird. ... And test project still works on 800.
That's sad :(
I think, without rewriting parts of code with async/await JetImageLoader would not work normally on wp7
Well, i dont think that all parts are needed to be replaced. That exception appears in LimitedStorageCache, during updating _currentCacheSizeInBytes.
For now, i'm re-checking assembly versions and stuff. It works in my sample project, but it crashes in my real project. Then, i assume, i can use locker instead of Interlocked. Afaik, they are a bit slower, but nothing is free (except BSD-licensed code). :)
Wtf.. i reinstalled all assemblies manually, now version are very same. However, it still crashes in my project, but works in sample one.
I found, why it didnt work in my real project: http://msdn.microsoft.com/en-us/library/windowsphone/develop/x629ff68%28v=vs.95%29.aspx
64-bit members of the Interlocked class are present but not supported.
I guess, i can just represent cache size in megabytes.
I'll check this when I'll be at home. At the moment I can suggest you to try different configurations of JetImageLoader, like NoCache, MemoryCache, StorageCache, you also can check UnlimitedStorageCache as implementation of storage cache
ok, i got it. I can change its type to int
and it will contain currentCacheSizeIn kilobytes or megabytes
or we can use lock
for incrementing
Check push request - it is already there :)
On the other hand, i had about 20-30 images 15-20 Kb each. I dont think that they are taking more than int32 bytes, Well, anyway, now it works more or less fine (regarding Increment problem).
ConvertBytesToMegabytes
from pull request works incorrectly, example:
long bytes = 123456;
int megaBytes = ConvertBytesToMegabytes(bytes); // == 0
I think I should use lock
to synchronize that incrementings and do not break existing usages of JetImageLoader
Hmmm.. let me see..
static void Main(string[] args)
{
Debug.WriteLine(ConvertBytesToMegabytes(1024));
Debug.WriteLine(ConvertBytesToMegabytes(1024 * 1024 - 1));
Debug.WriteLine(ConvertBytesToMegabytes(1024 * 1024));
Debug.WriteLine(ConvertBytesToMegabytes(1024 * 1024 + 1));
Debug.WriteLine(ConvertBytesToMegabytes(5654523));
Debug.WriteLine(ConvertBytesToMegabytes(56545245354353));
}
static int ConvertBytesToMegabytes(long bytes)
{
return (int) bytes >> 20;
}
This works. Simplicity rulezz :)
Can we go to the skype? (artem.zinnatullin)
I pushed fix with lock
to the develop branch, can you can pull it and check how it works?
https://github.com/artem-zinnatullin/jet-image-loader/tree/develop
Btw, subj is still there. :)
Did you find a solution for this issue? The one with
if (System.ComponentModel.DesignerProperties.IsInDesignTool)
{
return null;
}
does not help