Developer forum

Forum » Swift » DW 10 - Error in swift templates in local development

DW 10 - Error in swift templates in local development

Mateusz Struzik
Reply

Hi 

I have a question about local setup for DW 10 project. i followed this guide: Project Structure | Dynamicweb 10 Developer Documentation. But when i moved my files to .Files projecta lot of templates throwing an errors when i am trying to build .Fiels project. 

To get rid of some of them i add .Host project to references. 

Some error sample : 



Should i add some packages ? Or this behaviour is normall ? 

When i run host proj the app is starting normally 

Regards 

Mateusz 


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi

EditAddressViewModel is brand new - so what happens here is that your intellisense cache is not updated with the latest versions of viewmodels found in Dynamicweb.Users.Frontend.ManageAddresses namespace in Dynamicweb.Users package.

If you installed e.g.10.14 where that model is not present, or if you installed using release rings and have chosen a ring where this feature is not yet available, you can see stuff like this.

So you need to ensure that your project downloaded the latest versions of the nuget packages.

Also check if your dependencies are like below - meaning it will always be the latest DW 10 versions of the packages.

 

Here are instructions for both Visual Studio 2022 and Visual Studio Code to:

  1. Update NuGet packages (specifically Dynamicweb, with wildcard version 10.*)

  2. Reset IntelliSense cache

 

✅ Visual Studio 2022 (Full IDE)

Step 1: Update NuGet Package

Even though you're using Version="10.*", you still need to run a restore or force an update to pull the latest matching version.

Option A – Use NuGet Package Manager Console:

Open the console via:

Tools > NuGet Package Manager > Package Manager Console

Then run:

Update-Package Dynamicweb -Reinstall

This will reinstall the latest matching 10.x version based on your version range.

If you're in a solution and want to do it for all projects:

Update-Package Dynamicweb -Reinstall -ProjectName YourProjectName

Or for all packages in the solution (if you want to be thorough):

Update-Package -Reinstall

Step 2: Clear IntelliSense Cache

There is no direct “reset IntelliSense” button, but you can:

  1. Close Visual Studio.

  2. Delete the following folders (if they exist):

.vs/
bin/
obj/

You can automate this with PowerShell:

Get-ChildItem -Recurse -Force -Include bin,obj | Remove-Item -Recurse -Force
Remove-Item .vs -Recurse -Force

Then restart Visual Studio and rebuild the solution:

dotnet clean
dotnet build

This should refresh the IntelliSense cache and ensures you're using the latest assemblies.

✅ Visual Studio Code (with .NET SDK)

Assuming you're using the .NET CLI in VSCode:

Step 1: Update Package

Because of <PackageReference Include="Dynamicweb" Version="10.*" />, run:

dotnet restore

This will pull the latest 10.x version available.

To force it:

dotnet clean
dotnet restore --force

Step 2: Clear IntelliSense Cache

VSCode relies on the .vscode/, bin/, and obj/ folders for IntelliSense and build artifacts.

You can run:

rm -rf bin obj .vscode
dotnet clean
dotnet build

Or on Windows PowerShell:

Remove-Item -Recurse -Force bin,obj,.vscode
dotnet clean
dotnet build

This will clear stale caches and rebuild everything fresh, updating IntelliSense.

🔁 Summary Command Set

Tool Command(s)
Visual Studio Update-Package Dynamicweb -Reinstall+ delete .vs/, bin/, obj/
VS Code (CLI) dotnet cleandotnet restore --forcedelete bin/, obj/, .vscode/

BR Nicolai

 
Mateusz Struzik
Reply

Hi Nicolai 

 

Thanks  for this info, it helped but i am still getting some erros on swift templates some of them are probably normall and connected with this comment :
@* Red lines may be due to variables defined in the parent tempalte - There is no actual error *@

but here : 

i am getting error that :
'Files_Templates_Designs_Swift_Navigation_Navigation' does not contain a definition for 'Parameters' and no accessible extension method 'Parameters' accepting a first argument of type 'Files_Templates_Designs_Swift_Navigation_Navigation' could be found (are you missing a using directive or an assembly reference?)
 

But when i am checking model the properties are there both for params and nodes.

Could it be also connected with mismatch in swift version and DW version, we are using swfit : v1.26.8 and DynamicWeb 10.15.1 

Regards Mateusz 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

It should not be a version issue - if any the .net runtime of your project which should be .net 8.

It can also be your implicit usings of your project. Model.Nodes and Model.Parameters are of type IEnumerable<T> and IDictionary<string, object?> which are both in the System.Collections.Generic namespace - and might be missing.

In my version of the template (where I do not have your issue), I have these definitions in my template:

@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.Navigation.NavigationTreeViewModel>
@using System.IO
@using System.Text.RegularExpressions
@using Dynamicweb
@using Dynamicweb.Ecommerce.Orders


You can try to add this to the top of your template
using System;
using System.Collections.Generic;


Since the Parameters property has its value of a nullable type (IDictionary<string, object?>), you can also try to add this to the top of your template
#nullable enable

In your csproj file, check that you have implicit usings:
<ImplicitUsings>enable</ImplicitUsings>

And you can enable nullable for the project as well:
<Nullable>enable</Nullable>

 

 
Mateusz Struzik
Reply

I will add the usings. the nullability and ImplicitUsings are enabled. Is it strange that swift templates are missing some of usings ? this is fresh solution with Swift without modification directly from packages at least this is the info i have for team. Shouldn't swift template contains all necessary code ? 

 

Regards 

Mateusz 

 
Mateusz Struzik
Reply

Th usings are on place, what is strnage some of the templates throw error : 

this is the OffCanvasUtilityNavigation.cshtml view 

some of them are ok 


this is BreadcrumbNavigation.cshtml view

 

It is not very crucial thing for me as the lcoal solution is working but will be nice to have swift project without unnecessary errors 

Regards 

Mateusz 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Well, not all of these things are in our control - it is also related to your local environment - settings, caches, versions etc.

I do not have that error in my local solution.

Swift v1 templates work on DW9 and DW10 - nullability is not the same on the 2 DW versions - since not all the same props are nullable on DW10 and DW9 - and there are lots of other suttle differences. Swift 1 templates have not been developed in nullable context either. 

The error you have in your template you probably can get to go away - be resetting cache again after you changed it, or clean/rebuild or something like that. VS in particular can have some stuborn intellisense cache.

 
Mateusz Struzik
Reply

ok thanks, yeah vs could be stubborn 

 

You must be logged in to post in the forum