Issue after trying to use Enable-UDLogging

Hey Guys,

Hoping someone can help. I tried to enable the logging feature in my code. When I finished and killed out my dashboard. I now cant launch any dashboards again. I tried disabling the logging but nothing helps, I now just get an error as follows:

Application startup exception: System.MissingMethodException: Method not found: ‘Microsoft.Extensions.Logging.ILoggerFactory NLog.Extensions.Logging.ConfigureExtensions.AddNLog(Microsoft.Extensions.Logging.ILoggerFactory)’.
at UniversalDashboard.ServerStartup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime lifetime)
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

Thanks

This is typically an issue with another module being loaded into PowerShell that is conflicting with UD. It’s one of the reason in PowerShell Universal, dashboards run outside of the web server. If you do want to try Universal, we have a guide for migrating dashboards: https://docs.ironmansoftware.com/dashboard/dashboards/migrating-from-universal-dashboard-2.9

You might want to run a Get-Module to see what is loaded as something is probably using a different version of the NLog library.

I will look but this only happend after I enabled logging. No other items are being loaded.

So not sure how this would have happened. Any other thoughts? I was also running this directly from the powershell window and closing/reopening did not solve.

What PowerShell version are you using?

Name Value


PSVersion 5.1.17763.1007
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
BuildVersion 10.0.17763.1007
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Any more ideas? I cant seem to find out why this has happened or how to fix it.

Also just to add more, I checked it was not related to the users profile and its not it is effecting all users.

Can you verify that no other modules are loaded? Have you updated anything on this server? .NET Version specifically.

Some assembly is conflicting with the NLogger assembly.

Try running this:

[System.AppDomain]::CurrentDomain.GetAssemblies()

It should give you a list of the assemblies that are loaded and where they are loaded from. We are looking for NLog assemblies and Microsoft.Extensions.Logging.

No updates have been done.

Ok so I do see this when I run the command:

GAC Version Location


False v4.0.30319 C:\Program Files\WindowsPowerShell\Modules\UniversalDashboard.Community\2.9.0\net472\NLog.dll
False v4.0.30319 C:\Program Files\WindowsPowerShell\Modules\UniversalDashboard.Community\2.9.0\net472\NLog.Extensions.Logging.dll

GAC Version Location


False v4.0.30319 C:\Program Files\WindowsPowerShell\Modules\UniversalDashboard.Community\2.9.0\net472\Microsoft.Extensions.Logging.Abstractions.dll
False v4.0.30319 C:\Program Files\WindowsPowerShell\Modules\UniversalDashboard.Community\2.9.0\net472\Microsoft.Extensions.Logging.dll
False v4.0.30319 C:\Program Files (x86)\Devolutions\Remote Desktop Manager\Microsoft.Extensions.Logging.Abstractions.dll

How do I like them if they are not correct?

kill*

You can’t unload assemblies, like the one from Devolutions, once they are loaded into .NET. We need to figure out how that assembly is being loaded. Does Remote Desktop Manager have a PS module or is the Devolutions folder on the PSModulePath or PATH?

I’d check $Env:PSModulePath and $Env:PATH to see if it’s on either one of those. The other thing that could be happening is that when UD tries to load those assemblies, it’s finding the one in the RD Manager folder rather than UD for some reason.

So, I have been using devolutions powershell inside the PUD pages with no problems until the other day when I enabled the debugging on a new page. Since then PUD has been giving this error. So I imagine that when I enabled logging it also enabled it for the devolutions powershell too?

C:\Users\USER\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\Citrix\PowerShellModules;C:\Program Files\Citrix\XenDesktopPoshSdk\Module\Citrix.XenDesktop.Admin.V1\

C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Users\adm-ncavendish\AppData\Local\Microsoft\WindowsApps;

For the Devolutions powershell, I have to load it at the start of the scripts, but as I said that has never been an issue until the enable-udlogging was used. tried using disable-udlogging but that has not helped.

I don’t think you will be able to use Enable-UDLogging if you are loading that module. There will always be this assembly loading issue as all the assemblies are loaded into the same process. You might be able to enable logging first and then load the Devolutions PowerShell module second but that may give you problems executing commands in Devolutions.

As I mentioned before, it’s one of the big reasons for the architecture change in PowerShell Universal. It avoids these assembly loading problems by not loading those common assemblies into the same process as the PowerShell modules.

Ok right now my company is not willing to pay for it, and I have a number of PUD’s running but they all fail. I was only testing the logging one time not using it all the time and that seems to have broken everything. I can just rebuild a new windows server and move everything over and it will work again I was just trying to avoid that work. But if there is no other choice then I will. What ever happened the first time I loaded the logging has busted the setup for all services. Puds that where already running are still up its only when you try and launch new ones.

Can I use PU for free in the same way and just run seperate dashboards? Is it the same product? How would I move over to it?

Also I took the loading of the devolutions module out of the script but I still hit the same issue.

You can still use PU for free. It has pretty much the same licensing setup as UD and UD Community. You can run dashboards without authentication without having to buy anything. It has a v2.9 framework version of UD you can use your existing dashboards with. There are some changes you’ll need to make but those are documented here: https://docs.ironmansoftware.com/dashboard/dashboards/migrating-from-universal-dashboard-2.9

I realize it’s still a switch and work but I don’t know exactly why just enabling logging would cause this issue you all of a sudden. Enabling logging doesn’t persist anything anywhere except a log file. It seems like something has changed on the system, like upgrading the Devolutions module, that could cause this but you’ve already mentioned that nothing has changed so I’m unsure what’s happening.

The root cause is that there is an assembly version conflict with UD and Devolutions module.

Yeah very strange that this happened. Ok so I will look at the changes and build a new server and migrate. Thanks for all your help trouble shooting. Just one of those ghost in the machine moments.

Cool. Sorry it wasn’t a super easy solution.

If you do check out Universal, make sure to install the VS Code extension. It’ll make things a lot easier. https://marketplace.visualstudio.com/items?itemName=ironmansoftware.powershell-universal

Ok great, thanks again