-
This is more of a question about the latest build and what the minumum requirements are to make it work on existing addins. How much do I need to change to be context friendly? I have a number of addins that use the toolkit and were working happily up to toolkit version 2025.0.0 but with 2025.0.1 I started getting runtime errors when I call Host.GetService() where it seems my host is null. In those addins I'm using Microsoft.Extensions.Hosting v7 and Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(). I've made some test addins to try and understand whats going on using the latest nice3point templates. The repository contains projects using hosting and service containers with both v7 and v8 of the libraries and I'm running into the same problem. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
the point is for add-ins to use at least version 2025.0.1. If the first plugin that is loaded into Revit (alphabetically) will use 2025.0.0, all other plugins will also use 2025.0.0, this is the mechanics of Dotnet. All you need to do with existing plugins is recompile, you don't need to write any additional code. Are you testing in Revit 2025 ? If you have plugins that use RevitToolkit with an older version, you can replace the dlls in the folder, they are backwards compatible |
Beta Was this translation helpful? Give feedback.
-
Updated to GetRequiredService but that wasn't it. The problem is that host is not being initialised. Its null when Host.GetService is called. I can't see any differences in the way I'm starting host from RevitLookup. I'll have another look tomorrow and try and spot the difference. |
Beta Was this translation helpful? Give feedback.
-
This doesn't work
This does work
It doesn't look like anything else needs to change anything else. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the advice. Every day is a school day!! Its all projects but it's all fine if I just call Host.GetService from within void Execute in the command classes. |
Beta Was this translation helpful? Give feedback.
-
No problems now. I successfully upgraded everything on my end. It was simply that Host.GetService could not be called outside of void Execute(). I assume I'm in the wrong context until then. |
Beta Was this translation helpful? Give feedback.
This doesn't work
This does work