Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Pipeline.Invoke() throws exception when build with .Net 4.5

$
0
0
Hi,

I have created C# application for powershell hosting to run some of the Exchange cmdlets. Following is the code snippet used.

            Pipeline objPipe = space.CreatePipeline();
            Command objCommand = new Command(strCmdlet);
            foreach (KeyValuePair<String, String> param in mapParameters)
            {
                objCommand.Parameters.Add(param.Key, param.Value);
            }
            objPipe.Commands.Add(objCommand);
            try
            {
                return objPipe.Invoke();
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
                return null;
            }

I want to run above code on Exchange Server 2010. If above code is built with .Net 3.5 then it is working fine (on Exchange 2010). But if same code is built with .Net 4.5 thenreturn objPipe.Invoke(); is throwing following exception (on Exchange 2010).

System.Management.Automation.CmdletInvocationException: Value cannot be null.
Parameter name: parameters ---> System.ArgumentNullException: Value cannot be null.
Parameter name: parameters
   at Microsoft.Exchange.Configuration.Tasks.TaskVerboseStringHelper.FormatUserSpecifiedParameters(PropertyBag parameters)
   at Microsoft.Exchange.Configuration.Tasks.Task.LogCmdletIterationEvent()
   at Microsoft.Exchange.Configuration.Tasks.Task.BeginProcessing()
   at System.Management.Automation.Cmdlet.DoBeginProcessing()
   at System.Management.Automation.CommandProcessorBase.DoBegin()

On the contrary same code built with .Net 4.5, works fine on Exchange Server 2013. Can anybody help to find the cause of this exception if application is build for .Net 4.5 for Exchange Server 2010?

Regards,

Rohit

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>