DetailPage-MSS-KB

Microsoft small business knowledge base

Article ID: 828987 - Last Review: April 19, 2007 - Revision: 2.4

On This Page

SYMPTOMS

When a client is linked with the proxy DLL that the Soapsuds tool (Soapsuds.exe) generates, the client throws a remoting exception at run time. You may receive an error message that is similar to the following error message:
Unhandled Exception: System.Runtime.Remoting.RemotingException: Permission denied for activating type soap:TestClass, http://schemas.microsoft.com/clr/nsassem/EchoExeTest/ServerExe%2C%20Version%3D0.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull. Server stack trace: at System.Runtime.Remoting.Activation.ActivationListener.Activate(IConstructionCallMessage ctorMsg) at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(MethodBase mb, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

WORKAROUND

To work around this problem by linking the client, follow these steps:
  1. Run the Remoting Server application, and then generate the proxy by using the following command:
    soapsuds -url:<ServerUrl?wsdl> -oa:serverexe.dll
  2. Run the remoting server.
    1. Generate the proxy code by using the following command:
      soapsuds -url:<ServerUrl?wsdl> -gc
    2. Open the .cs file that Soapsuds.exe generates, remove the SoapType attribute from the class, and then build the proxy.
    3. Link the proxy to the client, and then run Soapsuds.exe.

      Note If the remoting server is not running, Soapsuds.exe generates an error and does not generate the proxy code.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Problem

  1. Use Notepad to create a text file. Paste the following code in the file:
    <configuration>
      <system.runtime.remoting>
        <application name="ServerExe">
        
          <channels>
            <channel port="9998" type="System.Runtime.Remoting.Channels.Http.HttpChannel, System.Runtime.Remoting,Version=1.0.5000.00, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
              <serverProviders>
                   <provider ref="wsdl" metadataEnabled="true" remoteApplicationMetadataEnabled="true" />
                   <formatter ref="soap" typeFilterLevel="Full" />
                   <formatter ref="binary" typeFilterLevel="Low" />
              </serverProviders>
            </channel>
            <channel port="9999" type="System.Runtime.Remoting.Channels.Tcp.TcpChannel, System.Runtime.Remoting,Version=1.0.5000.00, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          </channels>
       </application>
      </system.runtime.remoting>
    </configuration>
  2. Save the file as C:\ServerChannels.config.
  3. Use Notepad to create a new text file. Paste the following code in the file:
    <configuration>
      <system.runtime.remoting>
        <application>
    
          <service>
            <activated type="EchoExeTest.TestClass, ServerExe" />
          </service>
    
        </application>
      </system.runtime.remoting>
    </configuration>
    
  4. Save the file as C:\ServerCao.cfg.
  5. Use Notepad to create a new text file. Paste the following code in the file:
    using System;
    using System.Runtime.Remoting;
    using System.Runtime.Remoting.Metadata;
    using System.Runtime.Remoting.Metadata.W3cXsd2001;
    
    namespace EchoExeTest{
        [Serializable]
        public class testObject 
        {
            public int x;
            public int y;
        }
        [Serializable]
        public struct testStruct
        {
            public int x;
            public int y;
        }
        public class Server {
    
            public static int Main(string [] args) {
        
                Server servObj = new Server();
                servObj.Initialize(args);
                System.Console.WriteLine("Press ENTER to exit.");
                System.Console.ReadLine();
                return 0;
            }
    
            public void Usage() {
                Console.WriteLine(" Usage : ServerExe -chan:channel.config -mode:mode.config");
            }
    
            public  int Initialize(string[] args) {
                int ret=0;  
    
                if (args.Length == 0) 
                    Usage();
                for (int i=0;i<args.Length;i++) {
                    if (
                        String.Compare(args[i],"HELP", true) == 0 ||
                        String.Compare(args[i],"?", true) == 0 ||
                        String.Compare(args[i],"/h", true) == 0 ||
                        String.Compare(args[i],"-h", true) == 0 ||
                        String.Compare(args[i],"-?", true) == 0 ||
                        String.Compare(args[i],"/?", true) == 0
                    ) {
                        Usage();
                        return -1;
                    }
    
    
                    String arg = args[i];   
                    String value = null;
    
                    if (args[i][0] == '/' || args[i][0] == '-'){   
                        int index = args[i].IndexOf(':');
                        if (index != -1) {
    
                            arg = args[i].Substring(1, index-1);
                                //Make sure that a colon (:) is not the last character.
                            if (index == (args[i].Length - 1))
                                throw new Exception("Argument cannot be empty -> " + args[i]);
                            value = args[i].Substring(index+1);
                        }
                        else        
                            arg = args[i].Substring(1);     
                    }
    
                    //Process the input sources.
                    if (String.Compare(arg, "chan", true) == 0) {
                        RemotingConfiguration.Configure(value);
                    }
                    else if (String.Compare(arg, "mode", true) == 0) {
                        RemotingConfiguration.Configure(value);
                    }   
                }   
                ret=100;
                return ret;
            }
    
        }
    
        
        public class TestClass : MarshalByRefObject {
        
            public int EchoInt(int intval) {    
                Console.WriteLine("Method Called");
                return intval;
            }     
            public string EchoString(string strval) {    
                Console.WriteLine("Method Called");    
                return strval;
            }
            public DateTime EchoDateTime(DateTime dval) {
                return dval;
            }
            public void voidFunc(){
                return;
            }
            public int EchoParam(int intval) {
                return intval;
            }
            public void SendParam(int intval) {
                return;
            }
            public int GetParam() {
                return 10;
            }
            public int EchoRefParam(ref int intval) {
                intval++;
                return 100;
            }
            public void SendRefParam(ref int intval) {
                intval++;
                return;
            }
            public void OutParam(out int intval) {
                intval=100;
            }   
            public testStruct echoStruct(testStruct ts) {
                return ts;
            }
            public testObject echoObject(testObject to) {
                Console.WriteLine("Method Called");
                return to;
            }
            public int[] echoArray(int[] intArray) {
                return intArray;
            }
            
        }
    
    }
    
  6. Save the file as ServerExe.cs.
  7. Use Notepad to create a new text file. Paste the following code in the file:
    <configuration>
      <system.runtime.remoting>
        <application name="ClientExe">
        
          <channels>
            <channel port="0" type="System.Runtime.Remoting.Channels.Http.HttpChannel, System.Runtime.Remoting,Version=1.0.5000.00, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
            <channel port="0" type="System.Runtime.Remoting.Channels.Tcp.TcpChannel, System.Runtime.Remoting,Version=1.0.5000.00, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          </channels>
    
        </application>
      </system.runtime.remoting>
    </configuration>
  8. Save the file as C:\ClientChannels.config.
  9. Use Notepad to create a new text file. Paste the following code in the file:
    <configuration>
      <system.runtime.remoting>
        <application >
    
           <client url="http://localhost:9998/" >
            <activated type="EchoExeTest.TestClass, ServerExe" url="http://localhost:9998/TestClass.soap" />
           </client>
        </application>
      </system.runtime.remoting>
    </configuration>
  10. Save the file as C:\HttpCaoClient.cfg.
  11. Use Notepad to create a new text file. Paste the following code in the file:
    using System;
    using System.Runtime.Remoting;
    using EchoExeTest;
    
    public class ClientExeClass
    {
        public static int Main(String[] args)
        {
            const int PASS = 0xABBA;
            int parint = 12, outInt;
            string parstring = "hello";
            DateTime pardatetime = DateTime.Now;
            testStruct tStruct = new testStruct();
            tStruct.x = 100 ; tStruct.y = 200;
            testObject tObject = new testObject();
            tObject.x = 100 ; tObject.y = 200;
    
            Console.WriteLine("Start initiating the object.");
            ClientExeClass cec = new ClientExeClass();
            cec.Initialize(args);
            TestClass tClass = new TestClass();
            if(tClass == null){
                Console.WriteLine("Object not activated.");
                return 0;
            }
    
            try{        
                Console.WriteLine("Calling methods on the object.");
                
                int retInt = tClass.EchoInt(parint);
                if(retInt != parint)
                    throw new Exception("Failure in EchoInt method.");
                
                String retString = tClass.EchoString(parstring);
                if(retString != parstring)
                    throw new Exception("Failure in EchoString method.");
    
                DateTime retDval = tClass.EchoDateTime(pardatetime);
                if(retDval != pardatetime)
                    throw new Exception("Failure in EchoDateTime method.");
    
                tClass.voidFunc();
                tClass.SendParam(parint);
                retInt = tClass.GetParam();
                if(retInt != 10)
                    throw new Exception("Failure in GetParam method.");
    
                tClass.SendRefParam(ref parint);
                if(parint != 13)
                    throw new Exception("Failure in SendRefParam method.");
    
                retInt = tClass.EchoRefParam( ref parint);
                if((retInt != 100) || (parint != 14))
                    throw new Exception("Failure in EchoRefParam method.");
    
                tClass.OutParam(out outInt);
                if(outInt != 100)
                    throw new Exception("Failure in OutParam method.");
    
                testStruct retStruct = tClass.echoStruct(tStruct);
                if( (retStruct.x != tStruct.x) ||
                    (retStruct.y != tStruct.y))
                    throw new Exception("Failure in echoStruct method.");
    
                testObject retObject = tClass.echoObject(tObject);
                if( (retObject.x != tObject.x) ||
                    (retObject.y != tObject.y))
                    throw new Exception("Failure in echoObject method.");
    
                int[] parArray = new int[2];
                parArray[0]=1;
                parArray[1]=2;
    
                int[] retArray = tClass.echoArray(parArray);
                if( (retArray[0] != parArray[0]) ||
                    (retArray[1] != parArray[1]))
                    throw new Exception("Failure in echoArray method.");             
    
            }catch (Exception e) {
                Console.WriteLine(e);
                return 0;
            }
    
            return PASS;
        }
        
        public void Usage() {
            Console.WriteLine(" Usage : ClientExe -chan:Client.config -mode:wko/cao?client.config");
        }
    
        public  void Initialize(string[] args) {
            int ret=0;  
    
            if (args.Length == 0) 
            Usage();
            for (int i=0;i<args.Length;i++) {
            if (
                String.Compare(args[i],"HELP", true) == 0 ||
                String.Compare(args[i],"?", true) == 0 ||
                String.Compare(args[i],"/h", true) == 0 ||
                String.Compare(args[i],"-h", true) == 0 ||
                String.Compare(args[i],"-?", true) == 0 ||
                String.Compare(args[i],"/?", true) == 0
            ) {
                Usage();
                return;
            }
    
    
                String arg = args[i];   
            String value = null;
    
            if (args[i][0] == '/' || args[i][0] == '-'){   
                int index = args[i].IndexOf(':');
                if (index != -1) {
    
                arg = args[i].Substring(1, index-1);
                    //Make sure that a colon (:) is not the last character.
                if (index == (args[i].Length - 1))
                    throw new Exception("Argument cannot be empty. -> " + args[i]);
                value = args[i].Substring(index+1);
                }
                else    
                arg = args[i].Substring(1); 
            }
    
            //Process the input sources.
            if (String.Compare(arg, "chan", true) == 0) {
                Console.WriteLine(value);
                RemotingConfiguration.Configure(value);
                    }
            else if (String.Compare(arg, "mode", true) == 0) {
                Console.WriteLine(value);
                RemotingConfiguration.Configure(value);
            }   
            }   
            return;
        }
    
    }
    
  12. Save the file as C:\ClientExe.cs.
  13. Use Notepad to create a new text file. Paste the following code in the file:
    csc ServerExe.cs
    start serverexe -chan:serverchannels.config -mode:servercao.cfg
    soapsuds -url:http://localhost:9998/remoteapplicationmetadata.rem?Wsdl -oa:serverexe.dll
    csc /r:serverexe.dll clientexe.cs
    clientexe -chan:clientchannels.config -mode:httpcaoclient.cfg
    
  14. Save the file as c:\Build.bat.
  15. For Visual Studio .NET 2002, click Start, point to Programs, point to Microsoft Visual Studio .NET, point to Visual Studio .NET Tools, and then click Visual Studio .NET Command Prompt.

    For Visual Studio .NET 2003, click Start, point to Programs, point to Microsoft Visual Studio .NET 2003, point to Visual Studio .NET Tools, and then click Visual Studio .NET 2003 Command Prompt.
  16. At the command prompt, type C:, and then press the ENTER key.
  17. Type Build.bat, and then press the ENTER key.
  18. Run the remoting server application and the remoting client application.

    You may receive the error message that is mentioned in the "Symptoms" section of this article.

REFERENCES

For more information about Soapsuds.exe, visit the following Microsoft Developer Network(MSDN) Web site:
http://msdn2.microsoft.com/en-us/library/xd176a6c(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/xd176a6c(vs.71).aspx)


APPLIES TO
  • Microsoft .NET Framework 1.1
Keywords: 
kbproxydev kbcominterop kbremoting kbbug KB828987
Share
Additional support options
Ask The Microsoft Small Business Support Community
Contact Microsoft Small Business Support
Find Microsoft Small Business Support Certified Partner
Find a Microsoft Store For In-Person Small Business Support