DCD-SDK-Sample
DCD-SDK-Sample copied to clipboard
System.NullReferenceException when calling
System.NullReferenceException: 'Object reference not set to an instance of an object.' is received whenever I call: DymoSDK.App.Init();
I'm using the WPF sample here. Attempting this with "DCDSetup1.4.2.82.exe" installed (DYMO Connect for Desktop v1.4.2.82).
From reading through other issues, it seems like once you've got this framework working, if you change a single version of ANYTHING... it will break.
Does anyone have anything good to say about this mess?
Hello!
Yes, SkiaSharp version is important!
First things first, make sure the following NuGet packages installed (versions too!): DYMO.Connect.SDK (last version) SkiaShap (1.68.0) SkiaSharp.View (1.68.0)
It should work this way. Also for me, I have a "Print" service is a separated project, that's the only one using this packages. Using DryIoc container, calling a method from that service in a different project is only possible if I copy all SkiaShap..blabla...dll (3 or 4) files into that project's output folder. (It's only copying the SkiaSharp.dll and Dymo dll when I'm building the solution)
Hope this helps!
I have the same problem. I have checked all versions and everything seems to be correct, but unfortunately it does not work.
After you call DymoSDK.App.Init(); YOU MUST CALL DymoPrinter.Instance.GetPrinters(); at least once! Just by itself, or you can create a list for later use. That was the issue for me in one point.
After a move of despair, I comment out the line DymoSDK.App.Init() and it worked.
DymoSDK.App.Init() appears to always fails with a null exception when running inside the Visual Studio debugger. This applies to both the WPF and VB sample. If you launch the application outside of Visual Studio it should work fine.
I'm seeing the same NullException error on the App.Init() line. I downgraded thr SkiaSharp packages to 1.68 but it had no effect.
If I comment the line out, as it was suggested by @Panagiotis-Sklidas above, I get a KeyNotFoundException when trying to load the label file.
Also, as suggested by @sceBruce , if I run the compiled app outside of Visual Studio, or if I change the configuration to "Release" (so it doesn't use the Debugger), I get a ReflectionTypeLoadException on the next line after Init, when it tries to retrieve DymoLabel.Instance.
Does anyone have a WORKING, sample .NET app?
The VB sample is a Console application. Run the compiled application outside of Visual Studio. Console applications must be run with Administrator privilege. Launch the .exe with Run As Administrator.
I understand that the sample is a console app, and I ran it from an administrator-level command line.
After a lot of trial and error, I managed to run the sample successfully only after doing this:
- Restoring all the nuget package dependencies.
- Updating all the packages (Using Visual Studio's Package Manager) to their latest versions.
- Downgrading the package SkiaShat.Views to version 1.68
- Compiling the app, and then running VB_DYMOSDK_Sample.exe from a command line, outside of Visual Studio
Not being able to use the VS debugger with the SDK is a HUGE issue. It would be great if the developers could offer an alternative, or fix the issue in the Init() function.
To anyone still having this issue, try VS 2019. This error seems to be associated with VS 2022. Hopefully it gets addressed in the future.
I may have found a solution.
If your exception settings in Visual Studio are not the same as the default settings then take note of Visual Studio's exception settings on your computer before proceeding. Then resetting the exception settings back to default seemed to work for me. After you reset, restore your settings that aren't default by manually adding them.
I hope this works for everyone else having the same problem.