08-11-2023 08:19 AM - edited 08-11-2023 10:12 AM
Hello everyone,
I am having problem implementing Dependency injection with G# generic Create function. I have ObjA and ObjB. A is a parent class of B. I create objC and objD (all objs under G# framework, not related to previous objects, except through G# ofcourse)) and i encapsulate C & D in ObjA and ObjB. So for example i take objA, when I put objC_create.vi and objD_create.vi inside ObjA_create.vi, and run the G# generic Create to call ObjA, i get this error of 4000043. However, when i run the ObjA_create.vi itself, without using the G# generic Create, It runs completely fine.
Here are the two cases.
[case 1]: Use G# Generic Create: Provided Error 400043
[case2] Use ObjA_create.vi: works with no errors.
[NOTE] I noticed the error only started to happen when I started to add in ObjC and ObjD_create.vi inside ObjA_create.vi. Once i remove objC_create.vi and objD_create.vi, and run ObjA_create.vi, i don't have any error.....
I would really like to use the dependency injection method so that i can switch between objA and objB within my MAIN program. It's hard to share example code for this situation so i hope these snippets can explain my situation. NEED HELP! Thanks in advance!
[ps: I added a labview project, "DependencyInjection.zip", to demonstrate what I just explained].
Solved! Go to Solution.
08-14-2023 04:39 AM
You need to run G#Object.lvclass:G#Object_StartExternalCreateProcess.vi at the start of your application for case 1 to work.
There is a hint in the error message "Does a process really reply to the "External create object" event?", but I think the message could point out more specifically to check if the external create process VI is started.
08-14-2023 05:17 AM
Thank you very much! This indeed fixed the problem. It would be nice if the examples of G# included this implementation as an example, (or maybe i didnt see it). I traced the event loop structure that output this error, but i was unsure how to start an external process.
cheers,
08-14-2023 06:47 AM
@villanul wrote:Thank you very much! This indeed fixed the problem. It would be nice if the examples of G# included this implementation as an example, (or maybe i didnt see it). I traced the event loop structure that output this error, but i was unsure how to start an external process.
cheers,
There is a 'short' named example: G# - DependencyInjectionUsingExternalCreateProcessWithDefaultConstructor.vi