Security exception when increasing maxReceivedMessageSize for XBAP [modified]
-
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
-
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
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 ArticlesJust a grain of sand on the worlds beaches.
-
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 ArticlesJust a grain of sand on the worlds beaches.
-
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
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 ArticlesJust a grain of sand on the worlds beaches.
-
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 ArticlesJust a grain of sand on the worlds beaches.
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
-
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
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 ArticlesJust a grain of sand on the worlds beaches.
-
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 ArticlesJust a grain of sand on the worlds beaches.
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
-
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
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 ArticlesJust a grain of sand on the worlds beaches.
-
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
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.