473,785 Members | 2,434 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem when using windows services

This code works fine in Windows Application.
In Windows Application, I am able to zip the image files properly and it
totally contains 900MB
My problem is the same code which I used in my Windows Application,
does not work while I run it with Windows services.
In my Windows application I am able to zip the whole 900Mb without any
problems,
but in my windows services I am not able to zip the whole 900Mb.
In Windows Services it throws an error :SystemOutOfMem oryException
I am trying to zip all image files, example: idx,fim,rim
Below is the code I am using:

Please help me to find the solution to run this code properly in windows
services as well.

using Xceed.Compressi on;

using Xceed.FileSyste m;

using Xceed.Zip;

Xceed.Zip.Licen ser.LicenseKey = "ZINxx-xxxxx-xxxxx-xxxx";

public int MakeZipFile(str ing zipFileName, string[] filesToComp)
{
int retVal = 0;
DiskFolder tempFolder = new DiskFolder();
try
{
ZipArchive zip = new ZipArchive( new DiskFile( zipFileName ) );
zip.TempFolder = tempFolder;
try
{
zip.BeginUpdate ();
foreach( string file in filesToComp )
{
DiskFile fileToZip = new DiskFile( file );
fileToZip.CopyT o( zip, true );
++retVal;
}
}
finally
{
zip.EndUpdate() ;
}
}

catch(Exception exec)
{
throw new ZipException(ex ec.Message);
}
finally
{
}
return retVal;
}
}

}

// Windows Services --- main part of execution

string zipfilepath="C: \\temp\\pollNew .zip"; // all my image files will be
zipped in pollnew.zip
string[] pFiles=new string[7]; // pFiles contains all files
that I want to zip
pFiles[0]="D:\\New\\1218 07\\00007069.FC I";
pFiles[1]="D:\\New\\1218 07\\00007069.FI 2";
pFiles[2]="D:\\New\\1218 07\\00007069.FI M";
pFiles[3]="D:\\New\\1218 07\\00007069.ID X";
pFiles[4]="D:\\New\\1218 07\\00007069.RC I";
pFiles[5]="D:\\New\\1218 07\\00007069.RI 2";
pFiles[6]="D:\\New\\1218 07\\00007069.RI M";
MakeZipFile(str ing zipfilepath, string[] pFiles) // calling MakeZipFile
Function Here
Dec 28 '07 #1
5 2294
"vishruth" <vi******@discu ssions.microsof t.comwrote in message
news:A5******** *************** ***********@mic rosoft.com...
This code works fine in Windows Application.
In Windows Application, I am able to zip the image files properly and it
totally contains 900MB
My problem is the same code which I used in my Windows Application,
does not work while I run it with Windows services.
In my Windows application I am able to zip the whole 900Mb without any
problems,
but in my windows services I am not able to zip the whole 900Mb.
In Windows Services it throws an error :SystemOutOfMem oryException
I am trying to zip all image files, example: idx,fim,rim
Below is the code I am using:

Please help me to find the solution to run this code properly in windows
services as well.

using Xceed.Compressi on;

using Xceed.FileSyste m;

using Xceed.Zip;

Xceed.Zip.Licen ser.LicenseKey = "ZINxx-xxxxx-xxxxx-xxxx";

public int MakeZipFile(str ing zipFileName, string[] filesToComp)
{
int retVal = 0;
DiskFolder tempFolder = new DiskFolder();
try
{
ZipArchive zip = new ZipArchive( new DiskFile( zipFileName ) );
zip.TempFolder = tempFolder;
try
{
zip.BeginUpdate ();
foreach( string file in filesToComp )
{
DiskFile fileToZip = new DiskFile( file );
fileToZip.CopyT o( zip, true );
++retVal;
}
}
finally
{
zip.EndUpdate() ;
}
}

catch(Exception exec)
{
throw new ZipException(ex ec.Message);
}
finally
{
}
return retVal;
}
}

}

// Windows Services --- main part of execution

string zipfilepath="C: \\temp\\pollNew .zip"; // all my image files will
be
zipped in pollnew.zip
string[] pFiles=new string[7]; // pFiles contains all files
that I want to zip
pFiles[0]="D:\\New\\1218 07\\00007069.FC I";
pFiles[1]="D:\\New\\1218 07\\00007069.FI 2";
pFiles[2]="D:\\New\\1218 07\\00007069.FI M";
pFiles[3]="D:\\New\\1218 07\\00007069.ID X";
pFiles[4]="D:\\New\\1218 07\\00007069.RC I";
pFiles[5]="D:\\New\\1218 07\\00007069.RI 2";
pFiles[6]="D:\\New\\1218 07\\00007069.RI M";
MakeZipFile(str ing zipfilepath, string[] pFiles) // calling MakeZipFile
Function Here


Don't ever assume you have that huge block of free memory available in a
32-bit process. The fact that it works in a Windows program (say you were
lucky) doesn't mean it will work in another kind of application, note that
it's even possible that it will work all the time in your Windows
application one small change can easily spoil the party. If you need to make
sure that your memory demand as a chance to succeed, you'll have to
instantiate the MemoryFailPoint class from System.Runtime (assumes V2 of the
framework) before you initiate the memory consuming operation. Of course
this will need you to know the exact amount of memory needed for the
operation to succeed.
That said, I'm not entirely clear on why you need to run this from a Windows
Service, people tend to think that everything needs to run in the background
without even thinking about the complexities that come with developing
Services.

Willy.

Dec 28 '07 #2
As Willy pointed out, perhaps you do not need a Windows Service. If what you
need to do is make regular backups of images into a zip file, why not just
code it as a Console app and have Task Scheduler run it 1x a day?
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"vishruth" wrote:
This code works fine in Windows Application.
In Windows Application, I am able to zip the image files properly and it
totally contains 900MB
My problem is the same code which I used in my Windows Application,
does not work while I run it with Windows services.
In my Windows application I am able to zip the whole 900Mb without any
problems,
but in my windows services I am not able to zip the whole 900Mb.
In Windows Services it throws an error :SystemOutOfMem oryException
I am trying to zip all image files, example: idx,fim,rim
Below is the code I am using:

Please help me to find the solution to run this code properly in windows
services as well.

using Xceed.Compressi on;

using Xceed.FileSyste m;

using Xceed.Zip;

Xceed.Zip.Licen ser.LicenseKey = "ZINxx-xxxxx-xxxxx-xxxx";

public int MakeZipFile(str ing zipFileName, string[] filesToComp)
{
int retVal = 0;
DiskFolder tempFolder = new DiskFolder();
try
{
ZipArchive zip = new ZipArchive( new DiskFile( zipFileName ) );
zip.TempFolder = tempFolder;
try
{
zip.BeginUpdate ();
foreach( string file in filesToComp )
{
DiskFile fileToZip = new DiskFile( file );
fileToZip.CopyT o( zip, true );
++retVal;
}
}
finally
{
zip.EndUpdate() ;
}
}

catch(Exception exec)
{
throw new ZipException(ex ec.Message);
}
finally
{
}
return retVal;
}
}

}

// Windows Services --- main part of execution

string zipfilepath="C: \\temp\\pollNew .zip"; // all my image files will be
zipped in pollnew.zip
string[] pFiles=new string[7]; // pFiles contains all files
that I want to zip
pFiles[0]="D:\\New\\1218 07\\00007069.FC I";
pFiles[1]="D:\\New\\1218 07\\00007069.FI 2";
pFiles[2]="D:\\New\\1218 07\\00007069.FI M";
pFiles[3]="D:\\New\\1218 07\\00007069.ID X";
pFiles[4]="D:\\New\\1218 07\\00007069.RC I";
pFiles[5]="D:\\New\\1218 07\\00007069.RI 2";
pFiles[6]="D:\\New\\1218 07\\00007069.RI M";
MakeZipFile(str ing zipfilepath, string[] pFiles) // calling MakeZipFile
Function Here
Dec 28 '07 #3
Thank you for your suggestion Willy, but at the same time, I am helpless,
that I have to run it only with windows services, as my company demands that.
Can u justify me that if the same code for zipping image files about 900mb
works with windows application,why doesnt it work with windows services.
But the same code in windows services works for lower MB files but if it
crosses say about 250 MB then I face this problem "System OutOfMemory
Exception".
If u can share your thoughts with me, I could pass on the same to the person
who assigned me this task.
It will be of gr8 help,then.

Thanks,
Vishruth

"vishruth" wrote:
This code works fine in Windows Application.
In Windows Application, I am able to zip the image files properly and it
totally contains 900MB
My problem is the same code which I used in my Windows Application,
does not work while I run it with Windows services.
In my Windows application I am able to zip the whole 900Mb without any
problems,
but in my windows services I am not able to zip the whole 900Mb.
In Windows Services it throws an error :SystemOutOfMem oryException
I am trying to zip all image files, example: idx,fim,rim
Below is the code I am using:

Please help me to find the solution to run this code properly in windows
services as well.

using Xceed.Compressi on;

using Xceed.FileSyste m;

using Xceed.Zip;

Xceed.Zip.Licen ser.LicenseKey = "ZINxx-xxxxx-xxxxx-xxxx";

public int MakeZipFile(str ing zipFileName, string[] filesToComp)
{
int retVal = 0;
DiskFolder tempFolder = new DiskFolder();
try
{
ZipArchive zip = new ZipArchive( new DiskFile( zipFileName ) );
zip.TempFolder = tempFolder;
try
{
zip.BeginUpdate ();
foreach( string file in filesToComp )
{
DiskFile fileToZip = new DiskFile( file );
fileToZip.CopyT o( zip, true );
++retVal;
}
}
finally
{
zip.EndUpdate() ;
}
}

catch(Exception exec)
{
throw new ZipException(ex ec.Message);
}
finally
{
}
return retVal;
}
}

}

// Windows Services --- main part of execution

string zipfilepath="C: \\temp\\pollNew .zip"; // all my image files will be
zipped in pollnew.zip
string[] pFiles=new string[7]; // pFiles contains all files
that I want to zip
pFiles[0]="D:\\New\\1218 07\\00007069.FC I";
pFiles[1]="D:\\New\\1218 07\\00007069.FI 2";
pFiles[2]="D:\\New\\1218 07\\00007069.FI M";
pFiles[3]="D:\\New\\1218 07\\00007069.ID X";
pFiles[4]="D:\\New\\1218 07\\00007069.RC I";
pFiles[5]="D:\\New\\1218 07\\00007069.RI 2";
pFiles[6]="D:\\New\\1218 07\\00007069.RI M";
MakeZipFile(str ing zipfilepath, string[] pFiles) // calling MakeZipFile
Function Here
Dec 30 '07 #4
Is it possible that the zip library you are using is being
unnecessarily hungry here? I'm not familiar with the product (although
I recognise the name).

Off the wall, but have you tried the free but well-truested
sharpziplib? (and yes, I did notice that xceed sponsor icsharpcode).
(if you do, be sure to use a fixed size buffer; don't attempt to read
the entire source file at once).

Marc
Dec 30 '07 #5
For illustration, the following (using #ziplib) handles multi-hundred-
megabite files with a very small memory footprint - worth giving it a
whirl? (you might be able to further optimise it with some bespoke
buffer code).

using System;
using ICSharpCode.Sha rpZipLib.Zip;

class Program {
static void Main(string[] args) {
using (ZipFile zip = ZipFile.Create( args[0])) {
zip.BeginUpdate ();
for(int i = 1; i <args.Length; i++) {
zip.Add(args[i]);
}
zip.CommitUpdat e();
zip.Close();
}
}
}

Marc
Dec 30 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3289
by: bob | last post by:
I have created a simple Windows service in VB.Net which installs fine using InstallUtil.exe to install it to, for example "c:\test", or "c:\Windows\YellowBanana", but if I install it to "c:\Program Files\Test" it installs ok but will not start (no useful error message is given other than the usual annoying suggestion about having sufficient privileges). The problem only seems to happen with spaces, not long filenames. I have found a...
3
1506
by: Jay | last post by:
Hello, I have Windows Forms application which uses MS Access Database and a Pocket PC application which uses Datasets, Iam trying to pass Datasets between these applications using WebServices. Both these applications are shrink wrapped so they need to perform with little user configuration WebService/IIS is running on the computer having the Windows Application and Pocket PC connectss to the webservice through Active Sync.
4
6030
by: pepcag | last post by:
I used http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconalteringsoapmessageusingsoapextensions.asp as a template to create a very simple web method with soap extension. The code like this: public string HelloWorld() { return "Hello World.";
0
1338
by: graciezzzzz | last post by:
Hi all, I create a Web Service project called 'eSelectService' and another Class Library project called 'MonerisVO', and a Windows Form project called 'maps' as well. The reason why I need the Class Library project is because I don't want to pass more than 30 parameters when I try to invoke the Web Method. I used the class in Class Library as a value object to contain all the information I need.
5
19600
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was having a problem in the calling program. I searched online and found suggestions that I return an Array instead so I modified my code (below) to return an Array instead of an ArrayList. Now I get the message when I try to run just my webservice...
8
55682
by: Kevin D. | last post by:
Please note, I already posted this on the MySQL official forum, but received no response. I thought I'd try again in another location. My apologies to anyone reading this twice... Despite everything I've tried, I cannot get MySQL to start as a Windows service. However, I AM able to get it started via the mysqld-nt --console command. Here is my (funky) setup:
0
3922
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2 development client. Bur Its gives me following error message. I searched lots of things on net and tried on remote server but i didnt got suceess. Can any one tell me how to set TCP\IP connection protocol on server for particular instance. Becuase I think
5
24018
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2 development client. Bur Its gives me following error message. I searched lots of things on net and tried on remote server but i didnt got suceess. Can any one tell me how to set TCP\IP
2
1938
by: =?Utf-8?B?aGVsZmk=?= | last post by:
Hi all, I have replied with my own questions to an older post entry but after a while I thought it's better to start a new thread based on the previous one. Perhaps with the new thread I will catch more eyes and find someone who had the same problem and solved it or has more information about it. This is a summary of my problem:
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.