MarvinKlein1508 / SignaturePad

A simple to use blazor component to draw custom signatures.
MIT License
78 stars 12 forks source link

Error in the _Imports.razor #27

Closed Dsalazar09 closed 5 months ago

Dsalazar09 commented 5 months ago

Hello Marvin p1 p2

I am using your code, I installed the nuget package but when invoking it in the imports.razor file I get an error, what is the cause?

My solution is Maui Blazor hybrid. I don't know if that influences the error.

Thank you very much for your collaboration.

MarvinKlein1508 commented 5 months ago

Hi @Dsalazar09 thanks for reaching out! Could you tell me which .NET version you are using?

Dsalazar09 commented 5 months ago

Hi @MarvinKlein1508 .NET 7 p3

MarvinKlein1508 commented 5 months ago

@Dsalazar09 the component requires at least .NET 8. You should be able to update this easily. Luckily it's not as painful anymore as back in .NET Framework days.

.NET 7 ist EOL by next month anyways.

Dsalazar09 commented 5 months ago

Well @MarvinKlein1508 , I'll try to update the project, I hope I don't suffer too much. thank you

MarvinKlein1508 commented 5 months ago

@Dsalazar09 in case you cannot update yet, you can use the previous version of this package. It should only required .NET 6.

Dsalazar09 commented 5 months ago

I don't understand, could I use another version of your package? p1

MarvinKlein1508 commented 5 months ago

@Dsalazar09 yes. Try v7.5.0. This one is compatible with .NET 6

Dsalazar09 commented 5 months ago

@MarvinKlein1508 This v7.5.0 of the component did not generate an error, but for MAUI Blazor hybrid it did not work. gets the following error: [chromium] [INFO:CONSOLE(1)] "Exception has been thrown by the target of an invocation. [chromium] at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions) [chromium] at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions) [chromium] at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)

p2

MarvinKlein1508 commented 5 months ago

I've just created a new MAUI Blazor app and it works fine for me: grafik

Can you maybe share a small example repo?

Dsalazar09 commented 5 months ago

Thank you very much friend for sharing your code with me, there are several things that I adjusted and now it worked for me.

I deleted this part: private SignaturePadOptions _options = new SignaturePadOptions { LineCap = LineCap.Round, LineJoin = LineJoin.Round, LineWidth = 20 };

I initialized this just as you have it in the image you shared with me and it worked for me. public byte[] Signature { get; set; } = Array.Empty();

You are a crack, thank you very much.

Now I will try to save this in Sqlite and then send it to save in an api. I am very grateful for your help and timely response.

MarvinKlein1508 commented 5 months ago

Ah I see. Your issue was that you've not initialized the byte[] before. Therefore it tries to bind the component to null. You can use the options. I'Ve just tested it and it works fine as well. :)

MarvinKlein1508 commented 5 months ago

I've updated the README since this was missing in it. Thanks for sharing!