Possible caching error: "Umbraco.Web.PublishedModels.Image"
Hi,
I sometimes get the following error. Restarting my Umbraco v8 completely solves it for a while. It seems to return randomly after I have made changes to the document type of said page, so I guess it has something to do with caching ?
The error is:
The value "Umbraco.Web.PublishedModels.Image" is not of type "Umbraco.Web.PublishedModels.Image" and cannot be used in this generic collection.
Parameter name: value
And this is the code this error is triggered on:
@{
var img = Model.Value<IPublishedContent>("boekomslag2");
}
"boekomslag2" is a property of type Media Picker, and has a real image selected.
You can also get a similar error if you go to Media, create a new "File" and upload an image. Umbraco seems to recognize that it is indeed an image, because you can select this media item in your Media Picker, even though this proeprty is set "Pick only images".
But as soon as you select your "File", it generates a very similar error.
The value "Umbraco.Web.PublishedModels.Image" is not of type "Umbraco.Web.PublishedModels.Image" and cannot be used in this generic collection.
Parameter name: value
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: The value "Umbraco.Web.PublishedModels.Image" is not of type "Umbraco.Web.PublishedModels.Image" and cannot be used in this generic collection.
Parameter name: value
Source Error:
Line 318: [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder", "8.0.4")]
Line 319: [ImplementPropertyType("photos")]
Line 320: public Image Photos => this.Value("photos");
Line 321:
Line 322: ///
I have found this bug appears if you select images only in the multiple media picker settings.
Temporary workaraound:
You can copy the folder in settings > media types and set the permissions on your new folder to only accept images, then in media create a folder of the new type.
If you make the multiple media picker point to that folder then the editor can only choose files that have been uploaded to that folder which you have set to only allow images.
I'm running into this too on v8.0.2. I have a media picker that is set to "pick only images" (not a multiple image picker). I have an image selected on that property and the following code returns the same error.
var node = Model.Value<IPublishedContent>("image");
Error Message
The value "Umbraco.Web.PublishedModels.Image" is not of type "Umbraco.Web.PublishedModels.Image" and cannot be used in this generic collection.
Parameter name: value
The only "fix" I've found was to touch the web.config and the image showed up and the error was gone. Not sure if that will happen every time. I definitely think this is a bug with how many people are having the same issue. Do you know if this has been reported on the issue tracker?
Update: I didn't find the issue listed on the issue tracker, this issue is closed but it was the closest thing I could find and I posted there. I think it might be a similar issue.
I have the same problem. As Blake Clerke says, saving the web.config will fix it temporaryly, but obviously there is a danger that the error can show up after changing content. And when this is done by my customer he/she is not able to save the web.config.
This might be a problem with how asp.net is compiling the website after changes to the site. I'm not able to accurately describe the situation, but I'm regularly getting "Cannot bind source type LangloStore.ViewModels.ProductViewModel to model type LangloStore.ViewModels.ProductViewModel" type error on my local environment, and just now got it on our Dev environment in Umbraco Cloud. I've had it happen while debugging in VS before and have seen that the 2 types (with same name and should be) are loaded from different assemblies in asp.net's directories.
In my case, which is different from the issue here, it's unreated to image pickers, I'm using Umbraco 7.15, ModelBuilder in AppData mode, and Website project (required by Umbraco Cloud).
Forcing asp.net to recompile the site always fixes the problem, but obviously that is not something we want to do very often on our live site.
Possible caching error: "Umbraco.Web.PublishedModels.Image"
Hi,
I sometimes get the following error. Restarting my Umbraco v8 completely solves it for a while. It seems to return randomly after I have made changes to the document type of said page, so I guess it has something to do with caching ?
The error is:
And this is the code this error is triggered on:
"boekomslag2" is a property of type Media Picker, and has a real image selected.
You can also get a similar error if you go to Media, create a new "File" and upload an image. Umbraco seems to recognize that it is indeed an image, because you can select this media item in your Media Picker, even though this proeprty is set "Pick only images". But as soon as you select your "File", it generates a very similar error.
Any ideas ?
I upgraded to 8.0.2 and any changed code behind it returns the same error and restart on iis solves the problem
Also 8.0.2 and having the same issue.
Is there a solution to this error?
For me stop / start IIS ( not restart )
I'm also having this problem
The value "Umbraco.Web.PublishedModels.Image" is not of type "Umbraco.Web.PublishedModels.Image" and cannot be used in this generic collection. Parameter name: value Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: The value "Umbraco.Web.PublishedModels.Image" is not of type "Umbraco.Web.PublishedModels.Image" and cannot be used in this generic collection. Parameter name: value
Source Error:
Line 318: [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder", "8.0.4")] Line 319: [ImplementPropertyType("photos")] Line 320: public Image Photos => this.Value("photos"); Line 321: Line 322: ///
I have found this bug appears if you select images only in the multiple media picker settings.
Temporary workaraound:
You can copy the folder in settings > media types and set the permissions on your new folder to only accept images, then in media create a folder of the new type.
If you make the multiple media picker point to that folder then the editor can only choose files that have been uploaded to that folder which you have set to only allow images.
I'm running into this too on v8.0.2. I have a media picker that is set to "pick only images" (not a multiple image picker). I have an image selected on that property and the following code returns the same error.
Error Message The value "Umbraco.Web.PublishedModels.Image" is not of type "Umbraco.Web.PublishedModels.Image" and cannot be used in this generic collection. Parameter name: value
The only "fix" I've found was to touch the web.config and the image showed up and the error was gone. Not sure if that will happen every time. I definitely think this is a bug with how many people are having the same issue. Do you know if this has been reported on the issue tracker?
Update: I didn't find the issue listed on the issue tracker, this issue is closed but it was the closest thing I could find and I posted there. I think it might be a similar issue.
Had exact same senario and problem. Kicking the web.config solved the problem :)
I have the same problem. As Blake Clerke says, saving the web.config will fix it temporaryly, but obviously there is a danger that the error can show up after changing content. And when this is done by my customer he/she is not able to save the web.config.
So, does anybody know if this will be fixed?
This might be a problem with how asp.net is compiling the website after changes to the site. I'm not able to accurately describe the situation, but I'm regularly getting "Cannot bind source type LangloStore.ViewModels.ProductViewModel to model type LangloStore.ViewModels.ProductViewModel" type error on my local environment, and just now got it on our Dev environment in Umbraco Cloud. I've had it happen while debugging in VS before and have seen that the 2 types (with same name and should be) are loaded from different assemblies in asp.net's directories.
In my case, which is different from the issue here, it's unreated to image pickers, I'm using Umbraco 7.15, ModelBuilder in AppData mode, and Website project (required by Umbraco Cloud).
Forcing asp.net to recompile the site always fixes the problem, but obviously that is not something we want to do very often on our live site.
-Tor
Just to add another notch on the bedpost I too am experiencing this issue.
I've just upgraded to 8.1 and will monitor if this is still occurring (I can't remember if I've seen it since or not).
Luke
Just experienced this strange behavior. I am running 8.1.1 and restarting the server made it go away.
Same problem...
Issue was raised (and closed) here - https://github.com/umbraco/Umbraco-CMS/issues/5582
QUOTE: 'The problem is using Custom Media Types in Media Picker when "Pick only images" is on.'
I don't have Custom Media Types, but I did have "Pick only images" on. Have switched off and will report back if the problem pops up again...
is working on a reply...