How can I load WPFToolkit assembly in Powershell - powershell

I have installed WPF Toolkit:
Location: C:\Program Files\WPF Toolkit\v3.5.40320.1\WPFToolkit.dll
Name: WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Type: Library
I can load it by full path:
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\WPF Toolkit\v3.5.40320.1\WPFToolkit.dll")
But can't load by assembly name:
[System.Reflection.Assembly]::LoadWithPartialName("WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
[System.Reflection.Assembly]::Load("WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
What is a solution?

Loading by assembly name doesn't work because the WPFToolkit assembly is neither in GAC nor in the PowerShell directory. There are several options:
load it by path
add it to the GAC
change powershell.exe.config to look
in the WPF Toolkit directory
handle the AppDomain.AssemblyResolve
event (not particulary easy in
PowerShell V1)

Related

Could not load file or assembly System.Linq.Dynamic.Core Version=1.0.15.0

Added System.Linq.Dynamic.Core Version=1.0.15.0 from nuget in current Asp.net core 1.1 project. Added required moethods in library but when method is called error is thrown as "Could not load file or assembly 'System.Linq.Dynamic.Core, Version=1.0.15.0, Culture=neutral, PublicKeyToken=0f07ec44de6ac832'. The system cannot find the file specified"
Tried to restore the package but no use

Running migrate.exe from powershell for Cloud Services Project?

I'm trying to write a powershell script that runs migrations for a cloud service project:
$migrator = "C:\Path\EntityFramework.6.1.3\tools\migrate.exe"
$migrateCommand = "$migrator file.dll /StartUpDirectory=C:\path\bin\Test /connectionStringName:myconnection /startUpConfigurationFile:C:\path\app.config /verbose"
Invoke-Expression $migrateCommand
And I keep getting the following error when I run the script: "Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified."
I have copied migrate.exe to my bin folder where all the dll's are and I'm using absolute path's for the startupdirectory and configuration file. Can't seem to figure out what I'm missing? Also another question I had was could migrate.exe be only used with webrole/workerrole projects?
The problem is migrator was searching entityframework.dll in the same working directory. You could change the working directory to the folder which contains your entityframework.dll

System.IO.FileNotFoundException Could not load assembly System.Drawing

I meet this error in a Xamarin.forms project using WebView and local html base url:
Exception while loading assemblies: System.IO.FileNotFoundException:
Could not load assembly 'System.Drawing, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't
exist in the Mono for Android profile? Nom de fichier :
'System.Drawing.dll' à
Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference
reference, ReaderParameters parameters) à
Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1
assemblies, AssemblyDefinition assembly, Boolean topLevel) à
Xamarin.Android.Tasks.ResolveAssemblies.Execute() Almicantarat.Droid
I read that:
System.IO.FileNotFoundException: Could not load assembly System.Web in Mono for Android
but I don't know which client's source code I should compile.
I read that:
Could not load file or assembly 'System.Drawing, Version=4.0.0.0
but in my project, there is no reference to System.Drawing !!
See my references:
my android project references
Solved:
-> Close the solution
-> Delete all contents of the Packages folder (all the DLL's referenced through Nuget)
-> Restart the solution
-> Build (this will cause Nuget to get all DLL's again based on the packages.config)

Must I rebuild Nunit 2.6.2 to use it with .net 4.0?

When I try to run some tests with:
nunit-console.exe <mydll> /framework:net-4.0
I am rewarded with:
Unhandled Exception: System.IO.FileNotFoundException: Could not load
file or assembly 'nunit-console-runner, Version=2.6.2.12296,
Culture=neutral, PublicKeyToke n=96d09a1eb7f44a77' or one of its
dependencies. The system cannot find the file specified. File name:
'nunit-console-runner, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' at
NUnit.ConsoleRunner.Class1.Main(String[] args)
There is no file named nunit-console-runner anywhere.
When I leave off the /framework, all is well. However, I need the /framework as my goal is to debug as mixed-mode test failure on a 64-bit system.

32 bit Powershell: Use the ServerManager module?

I'm working with a 32 bit application that can run powershell snippets. I need to load the ServerManager module, which I would normally do with:
Import-Module ServerManager
But I get this error:
The specified module 'ServerManager' was not loaded because no valid module file was found in any module directory.
I assume, this is because the ServerManager module does not exist in the 64 bit modules directory, so I have tried the following:
Import-Module "C:\Windows\sysnative\WindowsPowerShell\v1.0\Modules\ServerManager"
But now I get the error:
Import-Module : Cannot load Windows PowerShell snap-in C:\Windows\assembly\GAC_MSIL\Microsoft.Windows.ServerManager.PowerSh
ell\6.1.0.0__31bf3856ad364e35\Microsoft.Windows.ServerManager.PowerShell.dll because of the following error: Unable to load
one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Loader Exceptions:
Could not load file or assembly 'Microsoft.Windows.ServerManager, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856
ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.Windows.ServerManager, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856
ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.Windows.ServerManager, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856
ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.Windows.ServerManager, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856
ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.Windows.ServerManager, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856
ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.Windows.ServerManager, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856
ad364e35' or one of its dependencies. The system cannot find the file specified.
At line:1 char:14
Any suggestions on how I could use the ServerManager module from within 32 bit powershell? Or another suggestion on how I could install the 'Desktop Experience' feature on Server 2008 R2 (without using the UI)?
Your only real choice here is to spawn a 64 bit instance of powershell.exe to process your server manager commands. Because the parent process is 32 bit, you'll have to use the same %windir%\sysnative trick to launch powershell.exe.
%windir%\sysnative\windowspowershell\v1.0\powershell.exe
-command '& { ipmo servermanager; add-windowsfeature foo }'
(wrapped for clarity)