using Rebex in PowerShell

0 votes
asked Sep 28, 2011 by rDrown888 (160 points)
edited Sep 29, 2011

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


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


Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Sep 29, 2011 by rDrown888 (160 points)
edited Sep 29, 2011

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>


commented Sep 29, 2011 by Lukas Pokorny (121,790 points)
edited Sep 29, 2011

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