title: An unhandled exception of type 'System.Security.SecurityException' occurred in mscorlib.dll
body: <p>my problem is the error mentioned in the title.</p>
  
  <p>I am trying to use an objects as CAO type. I've creasted proper assembly, serwer and the client.</p>
  
  <p>It occurs when I try to use the line:</p>
  
  <pre><code>JamesBondCar[] cars = { new JamesBondCar("one", 100, true, true), 
                                        new JamesBondCar("Two", 100, true, true), 
                                        new JamesBondCar("Three", 100, true, true) };
  CarProvider cp=new CarProvider(cars);
  </code></pre>
  
  <p>This works when I use default constructor.
  What might be the problem?</p>
  
  <p>Edit:
  This is the code for CarProvider:</p>
  
  <pre><code> public class CarProvider : MarshalByRefObject 
      {
          private ArrayList theJBCars = new ArrayList(); 
          public CarProvider()
          {
              Console.WriteLine("Utworzono CarProvider.");
              theJBCars.Add(new JamesBondCar("QMobile", 140, true, true));
              theJBCars.Add(new JamesBondCar("FLyer", 140, true, false));
              theJBCars.Add(new JamesBondCar("Swimmer", 140, false, true));
              theJBCars.Add(new JamesBondCar("BasicJBC", 140, false, false));
          }
          public CarProvider(JamesBondCar[] theCars)
          { 
              Console.WriteLine("Utworzono JamesBondCar za pomocą niestandardowego konstruktora.");
              theJBCars.AddRange(theCars);
          }
          public ArrayList GetAllAutos() 
          { return theJBCars; }
          public JamesBondCar GetJBCByIndex(int i)
          { return (JamesBondCar)theJBCars[i]; }
      }
  </code></pre>
  
  <p>App.config for the serwer:</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;system.runtime.remoting&gt;
      &lt;application&gt;
        &lt;service&gt;
          &lt;activated
              type="CarGeneralAsm.CarProvider,CarGeneralAsm"/&gt;
        &lt;/service&gt;
          &lt;channels&gt;
            &lt;channel ref="http" port="32469"/&gt;
          &lt;/channels&gt;
      &lt;/application&gt;
    &lt;/system.runtime.remoting&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>And the App.config for the client:</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;system.runtime.remoting&gt;
      &lt;application name="TestowanieTypówCAO"&gt;
        &lt;client
          url="http://localhost:32469"&gt;
          &lt;activated
            type="CarGeneralAsm.CarProvider,CarGeneralAsm"/&gt;
        &lt;/client&gt;
        &lt;channels&gt;
          &lt;channel ref="http"/&gt;
        &lt;/channels&gt;
      &lt;/application&gt;
    &lt;/system.runtime.remoting&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Edit2:</p>
  
  <p>Error msg and stack trace:</p>
  
  <pre><code>System.Security.SecurityException was unhandled
    _HResult=-2146233078
    _message=Żądanie nie powiodło się.
    HResult=-2146233078
    IsTransient=false
    Message=Żądanie nie powiodło się.
    RemoteStackTrace=
  Server stack trace: 
     w System.Array.InternalCreate(Void* elementType, Int32 rank, Int32* pLengths, Int32* pLowerBounds)
     w System.Array.CreateInstance(Type elementType, Int32 length)
     w System.Runtime.Serialization.Formatters.Soap.ObjectReader.ParseArray(ParseRecord pr)
     w System.Runtime.Serialization.Formatters.Soap.ObjectReader.ParseObject(ParseRecord pr)
     w System.Runtime.Serialization.Formatters.Soap.ObjectReader.Parse(ParseRecord pr)
     w System.Runtime.Serialization.Formatters.Soap.SoapHandler.StartChildren()
     w System.Runtime.Serialization.Formatters.Soap.SoapParser.ParseXml()
     w System.Runtime.Serialization.Formatters.Soap.SoapParser.Run()
     w System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler handler, ISerParser serParser)
     w System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream serializationStream, HeaderHandler handler)
     w System.Runtime.Remoting.Channels.CoreChannel.DeserializeSoapRequestMessage(Stream inputStream, Header[] h, Boolean bStrictBinding, TypeFilterLevel securityLevel)
     w System.Runtime.Remoting.Channels.SoapServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage&amp; responseMsg, ITransportHeaders&amp; responseHeaders, Stream&amp; responseStream)
  
  Exception rethrown at [0]: 
  
    Source=mscorlib
    GrantedSet=""
    PermissionState=&lt;PermissionSet class="System.Security.PermissionSet"
  version="1"
  Unrestricted="true"/&gt;
  
    RefusedSet=""
    Url=""
    StackTrace:
      Server stack trace: 
         w System.Array.InternalCreate(Void* elementType, Int32 rank, Int32* pLengths, Int32* pLowerBounds)
         w System.Array.CreateInstance(Type elementType, Int32 length)
         w System.Runtime.Serialization.Formatters.Soap.ObjectReader.ParseArray(ParseRecord pr)
         w System.Runtime.Serialization.Formatters.Soap.ObjectReader.ParseObject(ParseRecord pr)
         w System.Runtime.Serialization.Formatters.Soap.ObjectReader.Parse(ParseRecord pr)
         w System.Runtime.Serialization.Formatters.Soap.SoapHandler.StartChildren()
         w System.Runtime.Serialization.Formatters.Soap.SoapParser.ParseXml()
         w System.Runtime.Serialization.Formatters.Soap.SoapParser.Run()
         w System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler handler, ISerParser serParser)
         w System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream serializationStream, HeaderHandler handler)
         w System.Runtime.Remoting.Channels.CoreChannel.DeserializeSoapRequestMessage(Stream inputStream, Header[] h, Boolean bStrictBinding, TypeFilterLevel securityLevel)
         w System.Runtime.Remoting.Channels.SoapServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage&amp; responseMsg, ITransportHeaders&amp; responseHeaders, Stream&amp; responseStream)
      Exception rethrown at [0]: 
         w System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
         w System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)
         w System.Runtime.Remoting.Activation.IActivator.Activate(IConstructionCallMessage msg)
         w System.Runtime.Remoting.Activation.LocalActivator.DoRemoteActivation(IConstructionCallMessage ctorMsg)
         w System.Runtime.Remoting.Activation.LocalActivator.Activate(IConstructionCallMessage ctorMsg)
         w System.Runtime.Remoting.Activation.AppDomainLevelActivator.Activate(IConstructionCallMessage ctorMsg)
         w System.Runtime.Remoting.Messaging.ClientContextTerminatorSink.SyncProcessMessage(IMessage reqMsg)
         w System.Runtime.Remoting.Activation.ActivationServices.Activate(RemotingProxy remProxy, IConstructionCallMessage ctorMsg)
         w System.Runtime.Remoting.Proxies.RemotingProxy.InternalActivate(IConstructionCallMessage ctorMsg)
         w System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(IMessage reqMsg)
         w System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)
         w CarGeneralAsm.CarProvider..ctor(JamesBondCar[] theCars)
         w CarProviderClient.CarClient.Main(String[] args) w c:\Users\Paweł\Documents\Visual Studio 2013\Projects\CarProviderClient\CarProviderClient\CarClient.cs:wiersz 31
         w System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
         w System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
         w Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
         w System.Threading.ThreadHelper.ThreadStart_Context(Object state)
         w System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
         w System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
         w System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
         w System.Threading.ThreadHelper.ThreadStart()
    InnerException: 
  </code></pre>