File size: 28,822 Bytes
8c763fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Management.Automation.Host;
using System.Reflection;
using Dbg = System.Management.Automation.Diagnostics;
using InternalHostUserInterface = System.Management.Automation.Internal.Host.InternalHostUserInterface;
namespace System.Management.Automation.Remoting
{
/// <summary>
/// Executes methods; can be encoded and decoded for transmission over the
/// wire.
/// </summary>
internal class RemoteHostCall
{
/// <summary>
/// Method name.
/// </summary>
internal string MethodName
{
get
{
return _methodInfo.Name;
}
}
/// <summary>
/// Method id.
/// </summary>
internal RemoteHostMethodId MethodId { get; }
/// <summary>
/// Parameters.
/// </summary>
internal object[] Parameters { get; }
/// <summary>
/// Method info.
/// </summary>
private readonly RemoteHostMethodInfo _methodInfo;
/// <summary>
/// Call id.
/// </summary>
private readonly long _callId;
/// <summary>
/// Call id.
/// </summary>
internal long CallId
{
get
{
return _callId;
}
}
/// <summary>
/// Computer name to be used in messages.
/// </summary>
private string _computerName;
/// <summary>
/// Constructor for RemoteHostCall.
/// </summary>
internal RemoteHostCall(long callId, RemoteHostMethodId methodId, object[] parameters)
{
Dbg.Assert(parameters != null, "Expected parameters != null");
_callId = callId;
MethodId = methodId;
Parameters = parameters;
_methodInfo = RemoteHostMethodInfo.LookUp(methodId);
}
/// <summary>
/// Encode parameters.
/// </summary>
private static PSObject EncodeParameters(object[] parameters)
{
// Encode the parameters and wrap the array into an ArrayList and then into a PSObject.
ArrayList parameterList = new ArrayList();
for (int i = 0; i < parameters.Length; ++i)
{
object parameter = parameters[i] == null ? null : RemoteHostEncoder.EncodeObject(parameters[i]);
parameterList.Add(parameter);
}
return new PSObject(parameterList);
}
/// <summary>
/// Decode parameters.
/// </summary>
private static object[] DecodeParameters(PSObject parametersPSObject, Type[] parameterTypes)
{
// Extract the ArrayList and decode the parameters.
ArrayList parameters = (ArrayList)parametersPSObject.BaseObject;
List<object> decodedParameters = new List<object>();
Dbg.Assert(parameters.Count == parameterTypes.Length, "Expected parameters.Count == parameterTypes.Length");
for (int i = 0; i < parameters.Count; ++i)
{
object parameter = parameters[i] == null ? null : RemoteHostEncoder.DecodeObject(parameters[i], parameterTypes[i]);
decodedParameters.Add(parameter);
}
return decodedParameters.ToArray();
}
/// <summary>
/// Encode.
/// </summary>
internal PSObject Encode()
{
// Add all host information as data.
PSObject data = RemotingEncoder.CreateEmptyPSObject();
// Encode the parameters for transport.
PSObject parametersPSObject = EncodeParameters(Parameters);
// Embed everything into the main PSobject.
data.Properties.Add(new PSNoteProperty(RemoteDataNameStrings.CallId, _callId));
data.Properties.Add(new PSNoteProperty(RemoteDataNameStrings.MethodId, MethodId));
data.Properties.Add(new PSNoteProperty(RemoteDataNameStrings.MethodParameters, parametersPSObject));
return data;
}
/// <summary>
/// Decode.
/// </summary>
internal static RemoteHostCall Decode(PSObject data)
{
Dbg.Assert(data != null, "Expected data != null");
// Extract all the fields from data.
long callId = RemotingDecoder.GetPropertyValue<long>(data, RemoteDataNameStrings.CallId);
PSObject parametersPSObject = RemotingDecoder.GetPropertyValue<PSObject>(data, RemoteDataNameStrings.MethodParameters);
RemoteHostMethodId methodId = RemotingDecoder.GetPropertyValue<RemoteHostMethodId>(data, RemoteDataNameStrings.MethodId);
// Look up all the info related to the method.
RemoteHostMethodInfo methodInfo = RemoteHostMethodInfo.LookUp(methodId);
// Decode the parameters.
object[] parameters = DecodeParameters(parametersPSObject, methodInfo.ParameterTypes);
// Create and return the RemoteHostCall.
return new RemoteHostCall(callId, methodId, parameters);
}
/// <summary>
/// Is void method.
/// </summary>
internal bool IsVoidMethod
{
get
{
return _methodInfo.ReturnType == typeof(void);
}
}
/// <summary>
/// Execute void method.
/// </summary>
internal void ExecuteVoidMethod(PSHost clientHost)
{
// The clientHost can be null if the user creates a runspace object without providing
// a host parameter.
if (clientHost == null)
{
return;
}
RemoteRunspace remoteRunspaceToClose = null;
if (this.IsSetShouldExitOrPopRunspace)
{
remoteRunspaceToClose = GetRemoteRunspaceToClose(clientHost);
}
try
{
object targetObject = this.SelectTargetObject(clientHost);
MyMethodBase.Invoke(targetObject, Parameters);
}
finally
{
remoteRunspaceToClose?.Close();
}
}
/// <summary>
/// Get remote runspace to close.
/// </summary>
private static RemoteRunspace GetRemoteRunspaceToClose(PSHost clientHost)
{
// Figure out if we need to close the remote runspace. Return null if we don't.
// Are we a Start-PSSession enabled host?
IHostSupportsInteractiveSession host = clientHost as IHostSupportsInteractiveSession;
if (host == null || !host.IsRunspacePushed)
{
return null;
}
// Now inspect the runspace.
RemoteRunspace remoteRunspace = host.Runspace as RemoteRunspace;
if (remoteRunspace == null || !remoteRunspace.ShouldCloseOnPop)
{
return null;
}
// At this point it is clear we have to close the remote runspace, so return it.
return remoteRunspace;
}
/// <summary>
/// My method base.
/// </summary>
private MethodBase MyMethodBase
{
get
{
return (MethodBase)_methodInfo.InterfaceType.GetMethod(_methodInfo.Name, _methodInfo.ParameterTypes);
}
}
/// <summary>
/// Execute non void method.
/// </summary>
internal RemoteHostResponse ExecuteNonVoidMethod(PSHost clientHost)
{
// The clientHost can be null if the user creates a runspace object without providing
// a host parameter.
if (clientHost == null)
{
throw RemoteHostExceptions.NewNullClientHostException();
}
object targetObject = this.SelectTargetObject(clientHost);
RemoteHostResponse remoteHostResponse = this.ExecuteNonVoidMethodOnObject(targetObject);
return remoteHostResponse;
}
/// <summary>
/// Execute non void method on object.
/// </summary>
private RemoteHostResponse ExecuteNonVoidMethodOnObject(object instance)
{
// Create variables to store result of execution.
Exception exception = null;
object returnValue = null;
// Invoke the method and store its return values.
try
{
if (MethodId == RemoteHostMethodId.GetBufferContents)
{
throw new PSRemotingDataStructureException(RemotingErrorIdStrings.RemoteHostGetBufferContents,
_computerName.ToUpper());
}
returnValue = MyMethodBase.Invoke(instance, Parameters);
}
catch (Exception e)
{
// Catch-all OK, 3rd party callout.
exception = e.InnerException;
}
// Create a RemoteHostResponse object to store the return value and exceptions.
return new RemoteHostResponse(_callId, MethodId, returnValue, exception);
}
/// <summary>
/// Get the object that this method should be invoked on.
/// </summary>
private object SelectTargetObject(PSHost host)
{
if (host == null || host.UI == null) { return null; }
if (_methodInfo.InterfaceType == typeof(PSHost)) { return host; }
if (_methodInfo.InterfaceType == typeof(IHostSupportsInteractiveSession)) { return host; }
if (_methodInfo.InterfaceType == typeof(PSHostUserInterface)) { return host.UI; }
if (_methodInfo.InterfaceType == typeof(IHostUISupportsMultipleChoiceSelection)) { return host.UI; }
if (_methodInfo.InterfaceType == typeof(PSHostRawUserInterface)) { return host.UI.RawUI; }
throw RemoteHostExceptions.NewUnknownTargetClassException(_methodInfo.InterfaceType.ToString());
}
/// <summary>
/// Is set should exit.
/// </summary>
internal bool IsSetShouldExit
{
get
{
return MethodId == RemoteHostMethodId.SetShouldExit;
}
}
/// <summary>
/// Is set should exit or pop runspace.
/// </summary>
internal bool IsSetShouldExitOrPopRunspace
{
get
{
return
MethodId == RemoteHostMethodId.SetShouldExit ||
MethodId == RemoteHostMethodId.PopRunspace;
}
}
/// <summary>
/// This message performs various security checks on the
/// remote host call message. If there is a need to modify
/// the message or discard it for security reasons then
/// such modifications will be made here.
/// </summary>
/// <param name="computerName">computer name to use in
/// warning messages</param>
/// <returns>A collection of remote host calls which will
/// have to be executed before this host call can be
/// executed.</returns>
internal Collection<RemoteHostCall> PerformSecurityChecksOnHostMessage(string computerName)
{
Dbg.Assert(!string.IsNullOrEmpty(computerName),
"Computer Name must be passed for use in warning messages");
_computerName = computerName;
Collection<RemoteHostCall> prerequisiteCalls = new Collection<RemoteHostCall>();
// check if the incoming message is a PromptForCredential message
// if so, do the following:
// (a) prepend "PowerShell Credential Request" in the title
// (b) prepend "Message from Server XXXXX" to the text message
if (MethodId == RemoteHostMethodId.PromptForCredential1 ||
MethodId == RemoteHostMethodId.PromptForCredential2)
{
// modify the caption which is _parameters[0]
string modifiedCaption = ModifyCaption((string)Parameters[0]);
// modify the message which is _parameters[1]
string modifiedMessage = ModifyMessage((string)Parameters[1], computerName);
Parameters[0] = modifiedCaption;
Parameters[1] = modifiedMessage;
}
// Check if the incoming message is a Prompt message
// if so, then do the following:
// (a) check if any of the field descriptions
// correspond to PSCredential
// (b) if field descriptions correspond to
// PSCredential modify the caption and
// message as in the previous case above
else if (MethodId == RemoteHostMethodId.Prompt)
{
// check if any of the field descriptions is for type
// PSCredential
if (Parameters.Length == 3)
{
Collection<FieldDescription> fieldDescs =
(Collection<FieldDescription>)Parameters[2];
bool havePSCredential = false;
foreach (FieldDescription fieldDesc in fieldDescs)
{
fieldDesc.IsFromRemoteHost = true;
Type fieldType = InternalHostUserInterface.GetFieldType(fieldDesc);
if (fieldType != null)
{
if (fieldType == typeof(PSCredential))
{
havePSCredential = true;
fieldDesc.ModifiedByRemotingProtocol = true;
}
else if (fieldType == typeof(System.Security.SecureString))
{
prerequisiteCalls.Add(ConstructWarningMessageForSecureString(
computerName, RemotingErrorIdStrings.RemoteHostPromptSecureStringPrompt));
}
}
}
if (havePSCredential)
{
// modify the caption which is parameter[0]
string modifiedCaption = ModifyCaption((string)Parameters[0]);
// modify the message which is parameter[1]
string modifiedMessage = ModifyMessage((string)Parameters[1], computerName);
Parameters[0] = modifiedCaption;
Parameters[1] = modifiedMessage;
}
}
}
// Check if the incoming message is a readline as secure string
// if so do the following:
// (a) Specify a warning message that the server is
// attempting to read something securely on the client
else if (MethodId == RemoteHostMethodId.ReadLineAsSecureString)
{
prerequisiteCalls.Add(ConstructWarningMessageForSecureString(
computerName, RemotingErrorIdStrings.RemoteHostReadLineAsSecureStringPrompt));
}
// check if the incoming call is GetBufferContents
// if so do the following:
// (a) Specify a warning message that the server is
// attempting to read the screen buffer contents
// on screen and it has been blocked
// (b) Modify the message so that call is not executed
else if (MethodId == RemoteHostMethodId.GetBufferContents)
{
prerequisiteCalls.Add(ConstructWarningMessageForGetBufferContents(computerName));
}
return prerequisiteCalls;
}
/// <summary>
/// Provides the modified caption for the given caption
/// Used in ensuring that remote prompt messages are
/// tagged with "PowerShell Credential Request"
/// </summary>
/// <param name="caption">Caption to modify.</param>
/// <returns>New modified caption.</returns>
private static string ModifyCaption(string caption)
{
string pscaption = CredUI.PromptForCredential_DefaultCaption;
if (!caption.Equals(pscaption, StringComparison.OrdinalIgnoreCase))
{
string modifiedCaption = PSRemotingErrorInvariants.FormatResourceString(
RemotingErrorIdStrings.RemoteHostPromptForCredentialModifiedCaption, caption);
return modifiedCaption;
}
return caption;
}
/// <summary>
/// Provides the modified message for the given one
/// Used in ensuring that remote prompt messages
/// contain a warning that they originate from a
/// different computer.
/// </summary>
/// <param name="message">Original message to modify.</param>
/// <param name="computerName">computername to include in the
/// message</param>
/// <returns>Message which contains a warning as well.</returns>
private static string ModifyMessage(string message, string computerName)
{
string modifiedMessage = PSRemotingErrorInvariants.FormatResourceString(
RemotingErrorIdStrings.RemoteHostPromptForCredentialModifiedMessage,
computerName.ToUpper(),
message);
return modifiedMessage;
}
/// <summary>
/// Creates a warning message which displays to the user a
/// warning stating that the remote host computer is
/// actually attempting to read a line as a secure string.
/// </summary>
/// <param name="computerName">computer name to include
/// in warning</param>
/// <param name="resourceString">Resource string to use.</param>
/// <returns>A constructed remote host call message
/// which will display the warning.</returns>
private static RemoteHostCall ConstructWarningMessageForSecureString(string computerName,
string resourceString)
{
string warning = PSRemotingErrorInvariants.FormatResourceString(
resourceString,
computerName.ToUpper());
return new RemoteHostCall(ServerDispatchTable.VoidCallId,
RemoteHostMethodId.WriteWarningLine, new object[] { warning });
}
/// <summary>
/// Creates a warning message which displays to the user a
/// warning stating that the remote host computer is
/// attempting to read the host's buffer contents and that
/// it was suppressed.
/// </summary>
/// <param name="computerName">computer name to include
/// in warning</param>
/// <returns>A constructed remote host call message
/// which will display the warning.</returns>
private static RemoteHostCall ConstructWarningMessageForGetBufferContents(string computerName)
{
string warning = PSRemotingErrorInvariants.FormatResourceString(
RemotingErrorIdStrings.RemoteHostGetBufferContents,
computerName.ToUpper());
return new RemoteHostCall(ServerDispatchTable.VoidCallId,
RemoteHostMethodId.WriteWarningLine, new object[] { warning });
}
}
/// <summary>
/// Encapsulates the method response semantics. Method responses are generated when
/// RemoteHostCallPacket objects are executed. They can contain both the return values of
/// the execution as well as exceptions that were thrown in the RemoteHostCallPacket
/// execution. They can be encoded and decoded for transporting over the wire. A
/// method response can be used to transport the result of an execution and then to
/// simulate the execution on the other end.
/// </summary>
internal class RemoteHostResponse
{
/// <summary>
/// Call id.
/// </summary>
private readonly long _callId;
/// <summary>
/// Call id.
/// </summary>
internal long CallId
{
get
{
return _callId;
}
}
/// <summary>
/// Method id.
/// </summary>
private readonly RemoteHostMethodId _methodId;
/// <summary>
/// Return value.
/// </summary>
private readonly object _returnValue;
/// <summary>
/// Exception.
/// </summary>
private readonly Exception _exception;
/// <summary>
/// Constructor for RemoteHostResponse.
/// </summary>
internal RemoteHostResponse(long callId, RemoteHostMethodId methodId, object returnValue, Exception exception)
{
_callId = callId;
_methodId = methodId;
_returnValue = returnValue;
_exception = exception;
}
/// <summary>
/// Simulate execution.
/// </summary>
internal object SimulateExecution()
{
if (_exception != null)
{
throw _exception;
}
return _returnValue;
}
/// <summary>
/// Encode and add return value.
/// </summary>
private static void EncodeAndAddReturnValue(PSObject psObject, object returnValue)
{
// Do nothing if the return value is null.
if (returnValue == null) { return; }
// Otherwise add the property.
RemoteHostEncoder.EncodeAndAddAsProperty(psObject, RemoteDataNameStrings.MethodReturnValue, returnValue);
}
/// <summary>
/// Decode return value.
/// </summary>
private static object DecodeReturnValue(PSObject psObject, Type returnType)
{
object returnValue = RemoteHostEncoder.DecodePropertyValue(psObject, RemoteDataNameStrings.MethodReturnValue, returnType);
return returnValue;
}
/// <summary>
/// Encode and add exception.
/// </summary>
private static void EncodeAndAddException(PSObject psObject, Exception exception)
{
RemoteHostEncoder.EncodeAndAddAsProperty(psObject, RemoteDataNameStrings.MethodException, exception);
}
/// <summary>
/// Decode exception.
/// </summary>
private static Exception DecodeException(PSObject psObject)
{
object result = RemoteHostEncoder.DecodePropertyValue(psObject, RemoteDataNameStrings.MethodException, typeof(Exception));
if (result == null) { return null; }
if (result is Exception) { return (Exception)result; }
throw RemoteHostExceptions.NewDecodingFailedException();
}
/// <summary>
/// Encode.
/// </summary>
internal PSObject Encode()
{
// Create a data object and put everything in that and return it.
PSObject data = RemotingEncoder.CreateEmptyPSObject();
EncodeAndAddReturnValue(data, _returnValue);
EncodeAndAddException(data, _exception);
data.Properties.Add(new PSNoteProperty(RemoteDataNameStrings.CallId, _callId));
data.Properties.Add(new PSNoteProperty(RemoteDataNameStrings.MethodId, _methodId));
return data;
}
/// <summary>
/// Decode.
/// </summary>
internal static RemoteHostResponse Decode(PSObject data)
{
Dbg.Assert(data != null, "Expected data != null");
// Extract all the fields from data.
long callId = RemotingDecoder.GetPropertyValue<long>(data, RemoteDataNameStrings.CallId);
RemoteHostMethodId methodId = RemotingDecoder.GetPropertyValue<RemoteHostMethodId>(data, RemoteDataNameStrings.MethodId);
// Decode the return value and the exception.
RemoteHostMethodInfo methodInfo = RemoteHostMethodInfo.LookUp(methodId);
object returnValue = DecodeReturnValue(data, methodInfo.ReturnType);
Exception exception = DecodeException(data);
// Use these values to create a RemoteHostResponse and return it.
return new RemoteHostResponse(callId, methodId, returnValue, exception);
}
}
/// <summary>
/// The RemoteHostExceptions class.
/// </summary>
internal static class RemoteHostExceptions
{
/// <summary>
/// New remote runspace does not support push runspace exception.
/// </summary>
internal static Exception NewRemoteRunspaceDoesNotSupportPushRunspaceException()
{
string resourceString = PSRemotingErrorInvariants.FormatResourceString(
RemotingErrorIdStrings.RemoteRunspaceDoesNotSupportPushRunspace);
return new PSRemotingDataStructureException(resourceString);
}
/// <summary>
/// New decoding failed exception.
/// </summary>
internal static Exception NewDecodingFailedException()
{
string resourceString = PSRemotingErrorInvariants.FormatResourceString(
RemotingErrorIdStrings.RemoteHostDecodingFailed);
return new PSRemotingDataStructureException(resourceString);
}
/// <summary>
/// New not implemented exception.
/// </summary>
internal static Exception NewNotImplementedException(RemoteHostMethodId methodId)
{
RemoteHostMethodInfo methodInfo = RemoteHostMethodInfo.LookUp(methodId);
string resourceString = PSRemotingErrorInvariants.FormatResourceString(
RemotingErrorIdStrings.RemoteHostMethodNotImplemented, methodInfo.Name);
return new PSRemotingDataStructureException(resourceString, new PSNotImplementedException());
}
/// <summary>
/// New remote host call failed exception.
/// </summary>
internal static Exception NewRemoteHostCallFailedException(RemoteHostMethodId methodId)
{
RemoteHostMethodInfo methodInfo = RemoteHostMethodInfo.LookUp(methodId);
string resourceString = PSRemotingErrorInvariants.FormatResourceString(
RemotingErrorIdStrings.RemoteHostCallFailed, methodInfo.Name);
return new PSRemotingDataStructureException(resourceString);
}
/// <summary>
/// New decoding error for error record exception.
/// </summary>
internal static Exception NewDecodingErrorForErrorRecordException()
{
return new PSRemotingDataStructureException(RemotingErrorIdStrings.DecodingErrorForErrorRecord);
}
/// <summary>
/// New remote host data encoding not supported exception.
/// </summary>
internal static Exception NewRemoteHostDataEncodingNotSupportedException(Type type)
{
Dbg.Assert(type != null, "Expected type != null");
return new PSRemotingDataStructureException(
RemotingErrorIdStrings.RemoteHostDataEncodingNotSupported,
type.ToString());
}
/// <summary>
/// New remote host data decoding not supported exception.
/// </summary>
internal static Exception NewRemoteHostDataDecodingNotSupportedException(Type type)
{
Dbg.Assert(type != null, "Expected type != null");
return new PSRemotingDataStructureException(
RemotingErrorIdStrings.RemoteHostDataDecodingNotSupported,
type.ToString());
}
/// <summary>
/// New unknown target class exception.
/// </summary>
internal static Exception NewUnknownTargetClassException(string className)
{
Dbg.Assert(className != null, "Expected className != null");
return new PSRemotingDataStructureException(RemotingErrorIdStrings.UnknownTargetClass, className);
}
internal static Exception NewNullClientHostException()
{
return new PSRemotingDataStructureException(RemotingErrorIdStrings.RemoteHostNullClientHost);
}
}
}
|