November Happy Hour will be moved to Thursday December 5th.

Unable to upload images Object Reference not set to an instance

KK
KK
Vote:
 

Hi guys,

I tried to upload a png file to cms through the asset pane.

Login --> Edit --> Asset Pane --> For All Sites --> Media --> Upload Files --> select the png file (2.8 KB) --> Failed with msg 'Object Reference not set to an instance'

Any advice would be appreciated.

Thanks

#286112
Aug 25, 2022 12:28
Vote:
 

Hi KK, The stack trace should hopefully show up in the logs to help you along.

#286113
Aug 25, 2022 13:13
KK - Aug 25, 2022 15:17
Thanks Surjit. Can I ask how to get the stack trace?
Surjit Bharath - Aug 25, 2022 15:56
Do you have a log writer setup? Look at the output logs?
If not, are you running kestrel? You'll be able to see the stack trace just after the error in the console where kestrel is running.

Are you getting the error on DXP? Take a look at live viewer on paasportal.
Vote:
 

Have you got the Content Model setup to accept an png file. 

e.g. 

using EPiServer.Framework.DataAnnotations;
using ImagePointEditor;
using System.ComponentModel.DataAnnotations;

namespace Temp5.Models.Media;

[ContentType(GUID = "0A89E464-56D4-449F-AEA8-2BF774AB8730")]
[MediaDescriptor(ExtensionString = "jpg,jpeg,jpe,ico,gif,bmp,png")]
public class ImageFile : ImageData
{
    /// <summary>
    /// Gets or sets the copyright.
    /// </summary>
    /// <value>
    /// The copyright.
    /// </value>
    public virtual string Copyright { get; set; }

    [UIHint(ImagePoint.UIHint)]
    [Display(Name = "Focal point")]
    public virtual string ImageFocalPoint { get; set; }
}

See here for documentation on the subject : Media types and templates (optimizely.com) 

#286115
Edited, Aug 25, 2022 13:52
Vote:
 

Hi

I have the same issue, got the mediatypes registered as well. If I start an empty Optimizely project i get the same result, also after adding the mediatypes. Alloy and Foundations works fine.

/P

#299394
Apr 02, 2023 10:02
Minesh Shah (Netcel) - Apr 02, 2023 22:49
Can you share the source code of the Media File Model please ?
Vote:
 
[ContentType(GUID = "7182DAC0-33F2-441E-AEDF-0C3259D49DBC")]
[MediaDescriptor(ExtensionString = "jpg,jpeg,jpe,gif,bmp,png")]
public abstract class SiteImageData : ImageData
{
[Display(
Order = 10)]
[CultureSpecific]
public virtual string Alt { get; set; }
}
#299438
Edited, Apr 03, 2023 7:32
Vote:
 

@Pär remove the abstract declaration from your class.

[ContentType(GUID = "7182DAC0-33F2-441E-AEDF-0C3259D49DBC")]
[MediaDescriptor(ExtensionString = "jpg,jpeg,jpe,gif,bmp,png")]
public class SiteImageData : ImageData
{
    [Display(
        Order = 10)]
    [CultureSpecific]
    public virtual string Alt { get; set; }
}
#299440
Apr 03, 2023 7:44
Vote:
 

Thanks Eric, worked like a charm!

#299446
Apr 03, 2023 10:40
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.