.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

System.IO.Compression from Device to Database to Service

Posted By:      Posted Date: October 05, 2010    Points: 0   Category :.NET Framework


I have a Windows Mobile Forms application that uses the System.IO.Compression DeflateStream class to Compress a bitmap image of a signature, which it does well compressing from ~86kB to ~6kB.

Once compressed, the byte array is written to a SQL CE Database (into an Image datatype column), which is later transferred to a staging database via MS Sync Framework.

Once in the staging database, I have a Windows Service which will read the signature data, decompress it and turn it back into a bitmap.

Unfortunately, when I try to decompress the byte array, I get the following exception "Index was outside the bounds of the array.".

Before I introduced Compression, this system worked 100%.

Now, I've tested in the Client (Windows Mobile) application that I can compress the Image to a byte array, then decompress the byte array back to an image and that works. Also, I have the same Compress/Decompress helper methods in the Client and Server applications.

I'm wondering where the problem lies; Is there a difference between the Compact Framework 3.5 and .NET Framework 3.5 implementations of DeflateStream that renders them incompatible? Or is there some issue with writing a compressed Byte Array to an Image column in a table and reading it back?

Here is the code for my Compress/Decompress helper methods:

View Complete Post

More Related Resource Links

Team System: Team Foundation Server Event Service


Use the Team Foundation Server EventService to create and manage event subscriptions or create a Web service to receive and process events.

Brian A. Randell

MSDN Magazine May 2008

Service Station: What's new in System.Xml 2.0?


In this installment of Service Station, Aaron Skonnard takes a long hard look at System.Xml 2.0.

Aaron Skonnard

MSDN Magazine September 2006

System.ComponentModel.DescriptionAttribute not showing up in REST service

I am trying to set the description for a REST WCF service, but it doesn't seem to be working. Code is: [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]     [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]     [WebDispatchFormatterConfiguration("application/xml")]     [WebDispatchFormatterMimeType(typeof(WcfRestContrib.ServiceModel.Dispatcher.Formatters.PoxDataContract), "application/xml", "text/xml")]     [WebDispatchFormatterMimeType(typeof(WcfRestContrib.ServiceModel.Dispatcher.Formatters.DataContractJson), "application/json")]     [WebDispatchFormatterMimeType(typeof(WcfRestContrib.ServiceModel.Dispatcher.Formatters.FormUrlEncoded), "application/x-www-form-urlencoded")]     public class PublicAppointmentSchedulerSvc : IPublicAppointmentScheduler     {         IPublicAppointmentScheduler impl = new PublicAppointmentScheduler();         [WebDispatchFormatter]         [Description("Immediate or callback contact request")]         [WebInvoke(UriTemplate = "InitiateContact", Method = Verbs.Post)]  &n

problem rename sharepoint 2010 search service application admin database

Hi all, i have a problem that hopefully someone has an answer to.  i am not too familiar with sharepoint so please excuse my ignorance. we have sharepoint 2010 on a windows 2008r2 server.  everything seems to work fine.  but as you know, the default database names are horrendous.  i have managed to rename all of them, except for the "search service application" admin database. the default is: Search_Service_Application_DB_<guid> the other 2 databases (crawl and property) were renamed without a problem. we are following the article from technet on how to rename the search service admin db (http://technet.microsoft.com/en-nz/library/ff851878%28en-us%29.aspx).  it says to enter the following command: $searchapp | Set-SPEnterpriseSearchServiceApplication -DatabaseName "new database name" -DatabaseServer "dbserver" however, i get an error about identity being null.  no big deal, i add the -Identity switch and the name of my search service application.  but the real problem comes the error it throws:   Set-SPEnterpriseSearchServiceApplication : The requested database move was aborted as the associated search application is not paused. At line:1 char:54 + $searchapp | Set-SPEnterpriseSearchServiceApplication <<<<  -Identity "Search Service Application" -DatabaseName "ShareP

Access Database from another system..

I am using SqlExpress 2008, I have created a instance named "INSTANCEA" in one system as windows authontification mode and sql server authentification mode..  Its working well... But I can't access my instance from another system... while accessing the instance i have got the following message.... Cannot connect to NODEA\INSTANCEA. ------------------------------ ADDITIONAL INFORMATION: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 28 - Server doesn't support requested protocol) (Microsoft SQL Server, Error: -1)

Exposing WCF Service for multiple clients with the feature of multiple database support

i have ceated a WCF service and hosted it properly. now i want to Exposing this Service for multiple clients with the feature of multiple database support.In this functionality how could i do the proper multiple database management. what i am doing now:1. i am taking database string from the client.2. Then setting the refference of above provided database to the all functions call.ISSUE: if the mulitple clients calling the service at the same time and both are giving different database string then the database string provided by the clients is overlapping.....

Hide system database in SQL Management Studio

I am using SQL server 2008 . What i all want is to create a uses that can only see the ABCDatabase in Management studio onced login. And to achieve that:1- I have created a new user.2- Deny View all database right to that user.3-Set that user as Owner of ABCDatabaseNow on login that user cannot see other databases but still able to see the system databases. How can i hide those system databases from that user?

need a simple login page cus my hosting provider system wont allow me to have more than one database

I dont really write html code too well  but I manged to get my web site developed and deployed using the built in features such as drag n drop, master page and user account authentication that make web developing almost a codeless experience. However; my hosting provider system wont allow me to have more than one database, this causes problems becasue when I developed my web app using vb2010 web developer (asp.net v2) I used the built in web config tool to manage users for my site, now after I deployed to my domain it all worked ok with the exeption of the login page, when I tried to log in the system threw a error message saying "database not found." or a page of "gobble-dee-gook" that says the same thing When I contacted support (my hosting provider) they said i have to create a table of users in my database file via 2008 sql server, thats ok I can do that, but my real problem is I dont know how to write appropriate code to reference the table. So heres my problem:  I just want to have some kind of login page with a couple of txtboxes and a click button that maybe using the VB code behind or html checks the input variables "username" "password" against something that is hard coded into vb a string variable or a constant and then branches to Mainmenu.aspx if successfull. I just need it real simple, no fancy stuff just a login s

System.IO.Compression not as good as compressed folder

I'm getting much better compression when I make a compressed folder (Windows XP) than I am using DeflateStream or GZipStream.  I thought these were the same algorithms used in PKZIP and for compressing folders.  Why such bad compression? DeflateStream: 3544Kb -> 1261Kb GZipStream: 3544Kb -> 1261Kb Windows XP: 3544Kb -> 804Kb So how can I get the same compression ratio as Windows XP? Thanks, Jeremy

Can´t set up local system accounts as service accounts in sharepoint 2010

HI I made an inplace upgrade to sharepoint 2010. I want to setup performance point services. but it doesn´t allow me to set a local system account as the application pool account for performance point services application. It doesn´t allow me to register a new account it says The specified user account "domain\username" is a local account. Local accounts should only be used in stand alone mode. The application pool account for the site collection that I upgraded is a local system account so I don´t get it? I tried this http://sharepoint.microsoft.com/blogs/fromthefield/Lists/Posts/Post.aspx?ID=112 However the upgrade fails after this. Is there any way that I do the inplace upgrade and it would allow me to use local system accounts has service accounts? Without Active directory? Thanks      

Access from Reporting Service database in Sqlserver2005 to Sqlserver2008 R2 database

We are going to upgrade our databases from SQLServer 2005 to SQLServer 2008 R2. Today the databases including Reporting Services are running in SQLServer 2005 9.0.4211 and in a cluster environment. We are planning not to upgrade the Reporting Service database to Sqlserver 2008 R2. The Sqlserver2005 and Sqlserver2008 R2 will be run side-by-side.   My question is: Is it possible to access a database running in Sqlserver 2008 R2 from a Reporting service database that is running in Sqlserver 2005 (9.0.4211)?  

The operating system returned error 21(The device is not ready.)

Dear DBAs, A database backup job has failed for the last couple of days with below error. I see that there is no P drive for PP1DATA. When I tried to bring drives online to find P drive and bring it up I couldn't bring them online. Is the absence of P drive related to this error? Thank you,   ." failed with the following error: "The operating system returned error 21(The device is not ready.) to SQL Server during a write at offset 0x0000005ec32000 in file 'P:\PP1DATA1\PP1DATA1.mdf'. Additional messages in the SQL Server error log and system event log may provide more detail. This is a severe system-level error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.  BACKUP DATABASE is terminating abnormally."

could not start the database engine service in Sql Server 2005

Dear All,   I am not able to  start the sql server 2005 database engine services... Sql server 2005 server is installed in one machine(SERVER)  and we have 10 client machine connecting to the server     When i try to start the service from the Service.msc in the SERVER i am getting the following error   =================================== Cannot connect to KEYSKILL. =================================== An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (.Net SqlClient Data Provider) ------------------------------Error Number: 2Severity: 20State: 0 ------------------------------Program Location:    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)   at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverI

what is the better design for location of system database data / log files and user data/log file,

is there a guideline for better performance for system database data location log location, like tempdb location etc. also better location for user databases/data and log.

Database Service number does not change

I notice when I check to make sure the SP3 took I still see SQLExpress\9.0.3042 instead of 9.0.4035 for SP 3. The server management studio changed has to 9.0.4035 but not the database. Can some explain this?

System.ServiceModel.Security.SecurityNegotiationException in WCF RIA Service

Good day, I created a WCF RIA service application in Visual Studio 2008. However, when I run the application it posts this exception. I set the includeExceptionDetailInFaults to true: <behaviors> <serviceBehaviors> <behavior name="serviceBehavior"> <serviceDebug includeExceptionDetailInFaults="true"/> <serviceMetadata httpGetEnabled="true"/> </behavior> </serviceBehaviors> </behaviors> However, I still get the this error in my client app..... Any idea to diagnose the issue? or any suggestion on exception handling in WCF?? Thanks in advance!!

Question on WCF service with Linq to SQL on 64-bit system

I'm trying this question one more time since I realized the work in in a 64-bit environment. I have a WCF service which runs in production in a 32-bit environment using VS2008 and .NET 2.0. We made a big change to our environment (lots at the same time) and I moved the services to VS2010, .NET 4.0, and 64-bit processes.  I wrote a new service and deployed it under IIS.  If I browse to the service I get the example screen and clicking on the link gives me the metadata.  So all of that is working. In my services I create a Linq to SQL context, perform a query, then return the result set as an Array.  I wrapped the context creation with a using.  My tests returned an exception "Attempt to access an object that has already been disposed".  I traced it down and found that the code executes, forces the query, returns the results, exits the using statement (disposing the context properly) then exits the method.  The next thing I get is the exception, inside framework code, and it is linq code attempting to fulfill the query once again. I have searched until I'm blue in the face trying to find prior incidents and fixes but all I found was one post, two years ago, same problem with less debugging, and no answer to the problem other than 'don't use the using statement' which is a bad suggestion.  So for a work around I wrote a Co
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend