ehubcap
ehubcap

Reputation: 1

Error CS0571 'ResizeSettings.Scale.set', 'ImageBuilder.Current.get': cannot explicitly call operator or accessor

While debugging my asp.net core application, I got these exception popping up: Error CS0571 'ResizeSettings.Scale.set', 'ResizeSettings.Quality.set' and 'ImageBuilder.Current.get' derived from the code snip show below

Bitmap bitmap = new Bitmap(pictureLocalPath);
using (MemoryStream stream = new MemoryStream())
{
    Size size = this.CalculateDimensions(bitmap.Size, targetSize, ResizeType.LongestSide, true);
    ResizeSettings settings1 = new ResizeSettings();
    settings1.Width=size.Width;
    settings1.Height=size.Height;
    settings1.set_Scale(2); //error here
    settings1.set_Quality(this.mediaSettings_0.DefaultImageQuality); //error here
    ImageBuilder.get_Current().Build(bitmap, stream, settings1);//error here
    byte[] binary = stream.ToArray();
    this.SaveThumb(thumbLocalPath, thumbFileName, string.Empty, binary);
}

Upvotes: 0

Views: 310

Answers (1)

maccettura
maccettura

Reputation: 10818

It looks like you are using the ImageResizer library.

According to the docs, .Size and .Quality are both properties. And in C#, you set a property like this:

settings1.Scale = 2;
settings1.Quality = this.mediaSettings_0.DefaultImageQuality;

As for the ImageBuilder error, the docs have an example of how you are supposed to use it (again, using properties the right way):

ImageResizer.ImageBuilder.Current.Build(bitmap, stream, settings1);

Your error message is very clearly telling you what is wrong.

I highly recomend reading through the documentation of libraries you decide to use and more importantly following some more tutorials on the basics of C#, you will need to use properties quite a bit in your development.

Upvotes: 1

Related Questions