iText7 null reference exception on PdfFontFactory.CreateFont(StandardFonts.TIMES_ROMAN) VS2019 - visual-studio-2019

Hi All: I have a VS2019 console app project that generates PDFs. Everything was working fine a month ago. When I re-opened the project and tried to run it, I am receiving a nullreferenceexception error when trying to create the first font in the PdfDocument.
PdfFont bfTimes = PdfFontFactory.CreateFont(StandardFonts.TIMES_ROMAN);
throws:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=itext.io
StackTrace:
at iText.IO.Font.FontCache..cctor()
I've confirmed the PdfDocument exists, and the font above returns "true" for "isRegistered".
Nothing changed in the project, but I did update VSCommunity to 16.11.2 at some point in the past couple of weeks. Is there any way to get a better error description for what's happening?

i searched for that specific exception error and found this other post from a few weeks ago:
https://csharpforums.net/threads/using-a-winform-to-create-a-pdf-using-itext7.6406/
The suggestion to turn on "just my code" in the debugging options made the error go away like magic :o

Related

The call is ambiguous between the following methods or properties: 'QuickFix.Fields.Converters.DateTimeConverter.Nanosecond(System.DateTime)'

I try to run Quickfix\n project and I face the above error with 6846 warnings. Why does this happen ? I see that many resolve this error message by modifying the code (i mean general this error message & not especially for the project of quickfix\n) but I didn't write this code so that to be in somewhere mistake while I get the quickfix\n as project to run it

stm32f070rbt6 Stack pointer invalid address problem

I have currently changed to a new microcontroller, STM32F070RBT6, I have used the STM32CubeMx to set up the microcontroller, i currently have no code just HAL initialisation code, when i debug it comes up with error message saying " The stack pointer for stack 'CSTACK' (currently 0x20000E38) is outside the stack range (0x20000110 to 0x20000510)"
I have tried all today to find the error, thats why i created a new stm32cube project with only initialisation code to see if it was an error on my part or HALs, does anyone have any idea what is causing this error? I havn't provided code as the project only contains the startup file etc, I am also using IAR as the IDE

EXC_BAD_ACCESS code=1 because of #{}

I got a EXC_BAD_ACCESS code=1 because of a line like this:
NSDictionary* params = #{};
I didnt create the project, but i notice that have link to a c++ library, and have build setting that is not default (the setting generated by XCode). If i change this line by
NSDictionary* params = [NSDictionary new];
The issue is gone. Can it be something to do with the compiler's setting in project's build setting?
As a comment said this error is likely to be deep in your code. If the culprit is a zombie, the easiest way to find it is to run it (preferably in the latest Xcode, currently Xcode 8, as it has been improved) in profiler and choose "Zombies". When it fails, you can see the history of everything that has happened to the object.
Also, set an exception breakpoint. You may get a break when the error happens instead of in main, where the exception gets passed up.

How do I set MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure to false?

I'm using Xamarin and trying to run one of my apps in the iOS simulator but I am getting this error:
2015-10-07 12:38:02.715 MolinaCoding1iOS[1550:54337] Unhandled managed exception:
Could not initialize an instance of the type 'UIKit.UIImage': the native 'initWithContentsOfFile:' method returned nil.
It is possible to ignore this condition by setting MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure to false. (System.Exception)
How do I actually ignore this condition? If I should not ignore this...then what should I do?
Thanks
I got this problem solved by running "Clean" on my project (using Visual Studio). Right Click your project and select "Clean". Run the application afterwards.
You can ignore by adding the below statement just before you use that class/ method.
ObjCRuntime.Class.ThrowOnInitFailure = false;

System.AggregateException: One or more errors occured ---> MonoTouch.Design.Client.DesignerRemoteException

I have been working in storyboard designing app for IOS. No code, besides automatically generated one is written. After reopening storyboard file in Xamarin I got following error:
System.AggregateException: One or more errors occured ---> MonoTouch.Design.Client.DesignerRemoteException: System.ArgumentNullException: Argument cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2[MonoTouch.UIKit.UIImage,System.String].set_Item (MonoTouch.UIKit.UIImage key, System.String value) in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:216
at MonoTouch.Design.Server.ImageResourceManager.SetImage (System.String name, MonoTouch.UIKit.UIImage value) in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Server/ImageResourceManager.cs:79
at MonoTouch.Design.Server.SessionController+<PostImageResource>c__AnonStorey3.<>m__0 () in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Server/SessionController.cs:167
at MonoTouch.Design.NativeExtensions+<SafeInvokeOnMainThread>c__AnonStorey0.<>m__0 () in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Server/Util/NativeExtensions.cs:378
at MonoTouch.Design.Client.ServerProcessConnection.SendRequest (MonoTouch.Design.CommandRequest req, Boolean throwIfNotRunning) [0x0007f] in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:195
at MonoTouch.Design.Client.ServerProcessConnection.SendRequest[Object] (MonoTouch.Design.CommandRequest req, Boolean throwIfNotRunning) [0x00004] in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:202
at MonoTouch.Design.Client.ServerProcessConnection.PostResources (MonoTouch.Design.DesignSession session, MonoTouch.Design.ImageResource[] resources) [0x0003f] in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Client/Connection/ServerProcessConnection.cs:132
at MonoTouch.Design.Client.IPhoneDesignerSession+<SendImageResources>c__AnonStorey13.<>m__1 () [0x00019] in /Users/builder/data/lanes/1089/7d45bbe2/source/md-addins/Xamarin.Designer.iOS/MonoTouch.Design.Client/IPhoneDesignerSession.cs:1329
at System.Threading.Tasks.TaskActionInvoker+FuncInvoke`1[System.Object].Invoke (System.Threading.Tasks.Task owner, System.Object state, System.Threading.Tasks.Task context) [0x00000] in /Volumes/build-root-ramdisk/mono-3.6.0/mcs/class/corlib/System.Threading.Tasks/TaskActionInvoker.cs:242
at System.Threading.Tasks.Task.InnerInvoke () [0x00031] in /Volumes/build-root-ramdisk/mono-3.6.0/mcs/class/corlib/System.Threading.Tasks/Task.cs:548
at System.Threading.Tasks.Task.ThreadStart () [0x000d0] in /Volumes/build-root-ramdisk/mono-3.6.0/mcs/class/corlib/System.Threading.Tasks/Task.cs:438
Can anybody help to figure out what this means?
As far as I can tell the error is caused by the following:
iOS Designer opens the StoryBoard and tries to parse the XML inside.
Upon parsing it calls MonoTouch.Design.Server (which probably runs code against Xcode for rendering the XML). While doing so it encounters a ViewElement containing a UIImage. So then it tries to setup the UIImage using parameters stored in a Dictionary (filled using the same XML). When it tries to access that Dictionary for the parameters to yield to UIImage it puts in a 'null' for the key and this causes your error.
Now I don't know exactly what in your Storyboard causes this error as you haven't provided the Storyboard-file in question (nor can I guarantee I could find that error if you had), but you can try some of the following things to try and resolve the issue.
Try and open the Storyboard in Xcode instead of iOS Designer. It sometimes manages to fix corrupt Storyboards that iOS Designer can't handle.
Open the Storyboard in XML-view and have a look at the elements that have UIImages in them. Try and see if anyone of them has a 'strange' name, source, value or something.
Post the Storyboard here and see if anyone else can spot the error
I encountered a similar scenario in that the error message started exactly as in the original post. I could not open the storyboard both in Visual Studio 2015 and in Xamarin Studio 5.10.3 (build 51)
After spending some time in comparing the changes to the .csproj file i figured out that the image for ipad caused this issue for me. I do not know the actual reason for the original post but for me, i had an image to be used as the app logo for ipad and i had named it as "imagename#ipad.png". It turns out this freaks out the designer even though XCode 7 perfectly opens the storyboard.
Finally i renamed the image as "imagename~iPad.png" and that did the trick. Both VS 2015 and XS 5.10.3 are happy to open the storyboard!
Documentation from Xamarin below for working with images
https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_images/sizes-and-filenames/

Resources