workflow-core icon indicating copy to clipboard operation
workflow-core copied to clipboard

host.Start()启动后的host对象和从容器获取的IWorkflowHost对象不一样

Open zengxiansheng opened this issue 1 year ago • 1 comments

Describe the bug host.Start()启动后的host对象和从容器获取的IWorkflowHost对象不一样,从容器获取的IWorkflowHost对象无法启动工作流,提示工作流未注册。

` //启动代码片段 var host = provider.GetService<IWorkflowHost>(); host.RegisterWorkflow<TestWorkflow, MyDataClass>(); host.Start();

  CommonUtitl.workflowHost = host;  //保存对象全局使用

`

string id = "TestWorkflow"; int version = 1; string workflowId = null; var def = _registry.GetDefinition(id, version); //结果:null var def2 = CommonUtitl.workflowHost.Registry.GetDefinition(id, version); //结果:有值 var tt = CommonUtitl.workflowHost == _workflowHost; //结果:不相等 image

To Reproduce

Expected behavior 从容器获取的IWorkflowHost对象和host.Start();后一样

Additional context Add any other context about the problem here.

zengxiansheng avatar May 08 '24 04:05 zengxiansheng

You should not holding a singleton lifetime reference at CommonUtil, this violate the idea of IoC. The lifetime behavior should specified during class registry time.

payphonepf avatar Oct 11 '24 22:10 payphonepf