0 votes
by (160 points)
edited

I cannot get the Rebex libraries to load in PowerShell.

Exception calling "Load" with "1" argument(s): "Could not load file or assembly 'Rebex.Mail' or one of its dependencies. The system cannot find the file specified." At line:1 char:28 + [Reflection.Assembly]::Load <<<< ("Rebex.Mail") + CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : DotNetMethodException

and

using the path with [Reflection.Assembly]::LoadFrom() gives the same error.

Thanks!

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (160 points)
edited

well you are using .NET4, so you need to tell powershell to load the .NET4 environment

"The solution is pretty simple – just tell PowerShell to use a later version of the CLR. To do this, you need to create a config file, named PowerShell.Exe.Config, located in the same folder as PowerShell.Exe (and another one for PowerShellISE.Exe, or PowerShellISE.Exe.Config). These config files contain a small bit of XML to tell the system which version of the CLR to use. To access the .NET 4.0 versions, use the following:"

<?xml version="1.0"?> <configuration>

<startup useLegacyV2RuntimeActivationPolicy="true">

    <supportedRuntime version="v4.0.30319"/> 
    <supportedRuntime version="v2.0.50727"/> 
</startup>  </configuration>

see http://tfl09.blogspot.com/2010/08/using-newer-versions-of-net-with.html

by (144k points)
edited

If you don't need any .NET4 features in PowerShell, an easier solultion would be to simply use .NET2 build of Rebex Mail.

...