FredericDH | Posts: 51

Creating a package (Object reference not set to an instance of an object)

0 votes
Hi! I am trying to create an eSignLive package using the C# SDK. Below is the error I get when "sending" my package. Apparently, it seems that I forgot to assign a value in my package {System.NullReferenceException: Object reference not set to an instance of an object. at Silanis.ESL.SDK.SignerConverter.ToAPIRole(String roleIdName) at Silanis.ESL.SDK.DocumentPackageConverter.ToAPIPackage() at Silanis.ESL.SDK.EslClient.CreatePackage(DocumentPackage package) here is my code : Document document = new Document { Id = $"123456", Content = Convert.FromBase64String(base64StringElement?.Value), Name = fileNameElement?.Value, }; List documentsPackage = new List(); documentsPackage.Add(document); Signer signer = new Signer("[email protected]", "firstname", "lastname", new Authentication(AuthenticationMethod.EMAIL)); List sList = new List(); sList.Add(signer); Signature s = new Signature("[email protected]", 1, 45, 572); s.Id = new SignatureId("111"); documentsPackage[0].Signatures.Add(s); PackageId packageId = eslClient.CreatePackage(package); eslClient.SendPackage(packageId); DocumentPackage documentPackage = eslClient.GetPackage(packageId);

Approved Answer
mwilliams | Posts: 957

Reply to: Creating a package (Object reference not set to an instance of an object)

0 votes
You wouldn't have to build your package as you showed in your last post. That's just the makeup of the simple "all-in-one" examples that we usually show. You could add signers dynamically to a package after building the document package. For example:
DocumentPackage superDuperPackage =
PackageBuilder.NewPackageNamed(“Test Package .NET”)
.WithSettings(DocumentPackageSettingsBuilder
.NewDocumentPackageSettings()))
.Build();

Signer mysigner = SignerBuilder.NewSignerWithEmail("[email protected]")
                                .WithFirstName("FName")
                                .WithLastName("LName").Build();

superDuperPackage.addSigner(mysigner);
Then, you could do the same with documents. You could even build your signers dynamically into a collection like you were doing above and should be able to add them all at once with something like:
superDuperPackage.getSigners().addAll(Collection);
I've not tried the last one, but it should work. Let me know.

mwilliams | Posts: 957

Reply to: Creating a package (Object reference not set to an instance of an object)

0 votes
Try building your signer like this instead and see if it fixes that error.
Signer mysigner = SignerBuilder.NewSignerWithEmail("[email protected]")
                                .WithFirstName("FName")
                                .WithLastName("LName").Build();
You might need to go to a SignatureBuilder for your signature, too. Let me know if this solves this error.

FredericDH | Posts: 51

Reply to: Creating a package (Object reference not set to an instance of an object)

0 votes
Michael, Thanks for you answer. It actually works, however, I realize that this methods assumes that one wants to create a document package in only 1 line of code (see your example that I pasted below). In my case, I am building my package dynamically and I need to be able to assign x signers with y documents. Does that make sense ? That's why I was taking the approach mentioned in my original post. Regards, Frederic DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed("Test Package .NET") .WithSettings(DocumentPackageSettingsBuilder .NewDocumentPackageSettings()) .WithSigner(SignerBuilder .NewSignerWithEmail("[email protected]") .WithFirstName("Frederic") .WithLastName("Frederic")) .WithDocument(DocumentBuilder .NewDocumentNamed("sampleAgreement") .FromStream(fs, DocumentType.PDF) .WithSignature(SignatureBuilder .SignatureFor("[email protected]") .OnPage(0) .AtPosition(72, 144))) .Build();

FredericDH | Posts: 51

Reply to: Creating a package (Object reference not set to an instance of an object)

0 votes
Michael, Thank your for your help. While your example sounds like it would fix my issue, it doesn't seem that I can access those functions (addsigner() and getsigners()). My Silanis SDL is v11.0, do I have an old DLL ? Frederic

mwilliams | Posts: 957

Reply to: Creating a package (Object reference not set to an instance of an object)

0 votes
Oops. Sorry. I was in Java. :\. With the .NET SDK, you'd have to do the first way I said. The collection way doesn't seem to exist. My apologies. superDuperPackage.Signers.Add(mysigner);

FredericDH | Posts: 51

Reply to: Creating a package (Object reference not set to an instance of an object)

0 votes
Michael, No problem, Im sure youre constantly juggling between the two languages HA! :-) I'll try that and will keep you posted so that future people can beneficiate from this thread Frederic

mwilliams | Posts: 957

Reply to: Creating a package (Object reference not set to an instance of an object)

0 votes
Sounds good! Thank you!

FredericDH | Posts: 51

Reply to: Creating a package (Object reference not set to an instance of an object)

0 votes
Michael, Thanks, it worked after some "tweaking around"! Regards, Frederic

mwilliams | Posts: 957

Reply to: Creating a package (Object reference not set to an instance of an object)

0 votes
Great to hear!! Let us know whenever you have questions! :)

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off