Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Security exception when increasing maxReceivedMessageSize for XBAP [modified]

Security exception when increasing maxReceivedMessageSize for XBAP [modified]

Scheduled Pinned Locked Moved WPF
csharpwpfwcfdata-structuressecurity
9 Posts 3 Posters 25 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hashen
    wrote on last edited by
    #1

    Hi, I've spent a good couple of days trying without luck to solve this problem I've run into to with my WPF browser application. Basically this is what I have : A WCF service with a method that returns a large array which is called from my WPF browser application (XBAP). The XBAP is partial trust with the security zone set as "Internet". I'm using VS2008 team system. I need to increase the maxReceivedMessageSize so that the array can be passed to the XBAP. I'm using basicHttpBinding so I need to increase the maxBufferSize by the same amount as well. My app.config file for the XBAP looks like the following: openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="1000000" maxBufferPoolSize="524288" maxReceivedMessageSize="1000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> maxBytesPerRead="4096" maxNameTableCharCount="16384" /> binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" /> But when I change the maxReceivedMessageSize and maxBufferSize by any amount I get a "System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed." exception. The stack trace I get back is : Startup URI: http://{machine_name}/WpfBrowserApp/WpfBrowserApplication.xbap Application Identity: http://{machine_name}/WpfBrowserApp/WpfBrowserApplication.xbap#WpfBrowserApplication.xbap, Version=1.0.0.33, Culture=neutral, PublicKeyToken=d11ee682d0580e4f, processorArchitecture=msil/WpfBrow

    L 2 Replies Last reply
    0
    • H Hashen

      Hi, I've spent a good couple of days trying without luck to solve this problem I've run into to with my WPF browser application. Basically this is what I have : A WCF service with a method that returns a large array which is called from my WPF browser application (XBAP). The XBAP is partial trust with the security zone set as "Internet". I'm using VS2008 team system. I need to increase the maxReceivedMessageSize so that the array can be passed to the XBAP. I'm using basicHttpBinding so I need to increase the maxBufferSize by the same amount as well. My app.config file for the XBAP looks like the following: openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="1000000" maxBufferPoolSize="524288" maxReceivedMessageSize="1000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> maxBytesPerRead="4096" maxNameTableCharCount="16384" /> binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" /> But when I change the maxReceivedMessageSize and maxBufferSize by any amount I get a "System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed." exception. The stack trace I get back is : Startup URI: http://{machine_name}/WpfBrowserApp/WpfBrowserApplication.xbap Application Identity: http://{machine_name}/WpfBrowserApp/WpfBrowserApplication.xbap#WpfBrowserApplication.xbap, Version=1.0.0.33, Culture=neutral, PublicKeyToken=d11ee682d0580e4f, processorArchitecture=msil/WpfBrow

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Please read this post here: http://blogs.msdn.com/sanjeets/archive/2007/05/02/calling-a-asp-net-2-0-webservice-from-an-xbap.aspx[^] While not the exact same circumstances, I believe the solution will work for you.

      Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

      Just a grain of sand on the worlds beaches.

      H 1 Reply Last reply
      0
      • L Lost User

        Please read this post here: http://blogs.msdn.com/sanjeets/archive/2007/05/02/calling-a-asp-net-2-0-webservice-from-an-xbap.aspx[^] While not the exact same circumstances, I believe the solution will work for you.

        Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

        Just a grain of sand on the worlds beaches.

        H Offline
        H Offline
        Hashen
        wrote on last edited by
        #3

        Thanks for your help Karl. Yes this would indeed work but I need to get my solution working in partial trust as I would like it to be used in the Internet zone. Is there any way to get it working without installing certificates on all the client machines?

        1 Reply Last reply
        0
        • H Hashen

          Hi, I've spent a good couple of days trying without luck to solve this problem I've run into to with my WPF browser application. Basically this is what I have : A WCF service with a method that returns a large array which is called from my WPF browser application (XBAP). The XBAP is partial trust with the security zone set as "Internet". I'm using VS2008 team system. I need to increase the maxReceivedMessageSize so that the array can be passed to the XBAP. I'm using basicHttpBinding so I need to increase the maxBufferSize by the same amount as well. My app.config file for the XBAP looks like the following: openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="1000000" maxBufferPoolSize="524288" maxReceivedMessageSize="1000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> maxBytesPerRead="4096" maxNameTableCharCount="16384" /> binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" /> But when I change the maxReceivedMessageSize and maxBufferSize by any amount I get a "System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed." exception. The stack trace I get back is : Startup URI: http://{machine_name}/WpfBrowserApp/WpfBrowserApplication.xbap Application Identity: http://{machine_name}/WpfBrowserApp/WpfBrowserApplication.xbap#WpfBrowserApplication.xbap, Version=1.0.0.33, Culture=neutral, PublicKeyToken=d11ee682d0580e4f, processorArchitecture=msil/WpfBrow

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Give this a look: http://nerddawg.blogspot.com/2007/03/using-wcf-in-xbap.html[^]

          Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

          Just a grain of sand on the worlds beaches.

          H 1 Reply Last reply
          0
          • L Lost User

            Give this a look: http://nerddawg.blogspot.com/2007/03/using-wcf-in-xbap.html[^]

            Cheers, Karl My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

            Just a grain of sand on the worlds beaches.

            H Offline
            H Offline
            Hashen
            wrote on last edited by
            #5

            thanks karl, but the article doesn't really solve my issue. let me rephrase this then: Is the any other way I can send a large dataset across from a WCF service to an XBAP WPF browser app without changing the maxReceivedMessageSize settings as it seems there is no way to change the settings in partial trust as the "WebPermission" needed to do this cannot be granted. Can the setting be changed globally on the machine itself instead of in the application (like modifying the machine.config or something similar?) It seems really stupid that a simple task like this would be impossible

            L S 2 Replies Last reply
            0
            • H Hashen

              thanks karl, but the article doesn't really solve my issue. let me rephrase this then: Is the any other way I can send a large dataset across from a WCF service to an XBAP WPF browser app without changing the maxReceivedMessageSize settings as it seems there is no way to change the settings in partial trust as the "WebPermission" needed to do this cannot be granted. Can the setting be changed globally on the machine itself instead of in the application (like modifying the machine.config or something similar?) It seems really stupid that a simple task like this would be impossible

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Hashen wrote:

              Is the any other way I can send a large dataset across from a WCF service

              Any way to break the dataset into smaller pieces and merge the parts on the XBAP side? Can you compress it and ship the compressed bytes across the wire? Are you using efficient binary serialization for the dataset?

              Hashen wrote:

              Can the setting be changed globally on the machine itself instead of in the application (like modifying the machine.config or something similar?)

              What setting? Any setting in web.config, can be set in machine.config.

              Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

              Just a grain of sand on the worlds beaches.

              H 1 Reply Last reply
              0
              • L Lost User

                Hashen wrote:

                Is the any other way I can send a large dataset across from a WCF service

                Any way to break the dataset into smaller pieces and merge the parts on the XBAP side? Can you compress it and ship the compressed bytes across the wire? Are you using efficient binary serialization for the dataset?

                Hashen wrote:

                Can the setting be changed globally on the machine itself instead of in the application (like modifying the machine.config or something similar?)

                What setting? Any setting in web.config, can be set in machine.config.

                Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

                Just a grain of sand on the worlds beaches.

                H Offline
                H Offline
                Hashen
                wrote on last edited by
                #7

                Karl Shifflett wrote:

                Any way to break the dataset into smaller pieces and merge the parts on the XBAP side?

                This would be possible but not ideal

                Karl Shifflett wrote:

                Can you compress it and ship the compressed bytes across the wire?

                Could you point me to an example on how I can do this for an object array please?

                Karl Shifflett wrote:

                Are you using efficient binary serialization for the dataset?

                I'm not quite sure what you are referring to when you say efficient binary serialization. Could you please elaborate a bit for me.

                Karl Shifflett wrote:

                What setting? Any setting in web.config, can be set in machine.config.

                I'm reffering to the maxReceivedMessageSize and maxBufferSize setting for the basicHttpBinding that I'm using. My thinking was that if I could increase these settings globally and permanently on the machine then the application would take the increased values as default and there would be no need for the application to request for web permission to increase these values. Thanks for all your help so far

                L 1 Reply Last reply
                0
                • H Hashen

                  Karl Shifflett wrote:

                  Any way to break the dataset into smaller pieces and merge the parts on the XBAP side?

                  This would be possible but not ideal

                  Karl Shifflett wrote:

                  Can you compress it and ship the compressed bytes across the wire?

                  Could you point me to an example on how I can do this for an object array please?

                  Karl Shifflett wrote:

                  Are you using efficient binary serialization for the dataset?

                  I'm not quite sure what you are referring to when you say efficient binary serialization. Could you please elaborate a bit for me.

                  Karl Shifflett wrote:

                  What setting? Any setting in web.config, can be set in machine.config.

                  I'm reffering to the maxReceivedMessageSize and maxBufferSize setting for the basicHttpBinding that I'm using. My thinking was that if I could increase these settings globally and permanently on the machine then the application would take the increased values as default and there would be no need for the application to request for web permission to increase these values. Thanks for all your help so far

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Are you sending a dataset or an array to your application using WCF? Datasets since .NET 2.0 support binary serialization. http://msdn.microsoft.com/msdnmag/issues/04/10/CuttingEdge/[^] http://www.knowdotnet.com/articles/binaryserialization.html[^] http://objectsharp.com/cs/blogs/datasetfaq/archive/2004/06/10/614.aspx[^] I just don't know about the very last question. Have you set the values in the web.config or machine.config in the section? Maybe your getting conflicts with the IIS and WCF settings?

                  Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

                  Just a grain of sand on the worlds beaches.

                  1 Reply Last reply
                  0
                  • H Hashen

                    thanks karl, but the article doesn't really solve my issue. let me rephrase this then: Is the any other way I can send a large dataset across from a WCF service to an XBAP WPF browser app without changing the maxReceivedMessageSize settings as it seems there is no way to change the settings in partial trust as the "WebPermission" needed to do this cannot be granted. Can the setting be changed globally on the machine itself instead of in the application (like modifying the machine.config or something similar?) It seems really stupid that a simple task like this would be impossible

                    S Offline
                    S Offline
                    Stephen42
                    wrote on last edited by
                    #9

                    Yes this is possible. I finally found the answer to this here... http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2196129&SiteID=1 Quote: "The problem is not with MaxReceivedMessageSize but with MaxBufferSize. MaxBufferSize seems to have a limit of 65536 in partial trust mode. To get around this you can leave MaxBufferSize at 65536 and change the transferMode to Streamed or StreamedResponse." After doing this you can set the MaxReceivedMessageSize to as big as you need.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups