|
I found this one easy to use, and reliable:
CSharpZip[^]
Gary
|
|
|
|
|
I am not sure if it supports Japanese fonts, but I agree with Gary, the one from icsharpcode.com is definately a good and easy one to work with.
Steve Maier, MCSD MCAD
|
|
|
|
|
Like Steve, I also agree with Gary. Besides, the java.util.zip.* class in vjslib.dll also has a bug where, IIRC, a ZIP created with it can't be unzipped by "standard" ZIP libraries and applications.
#ziplib (the link Gary gave you) is commonly used by many projects.
I wanted to add, too, that the .NET Framework 2.0 will include ZIP classes (and support for derivative compression streams) in the BCL (base class library), along with many other great features.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hey Elena,
I recently used SharpZipLib and so far it hasn't given me any problems.
Here is the URL:
http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx
I hope it helps.
Cheers,
Suthan
|
|
|
|
|
|
I was previously told by one of the "guru's" of this site that this was not a c# issue. That is not correct because C# is the only language that supports Web Page Comments.
When I use the "Build Comment Web Pages" on the Tools MEnu of VS.NET 2003, the following type of HTML comment is generated at the top of every HTM file
""
I have recently installed Service Pack 2 of Windows XP. Now when the above comment is detetected by IE6, the Internet Zone is considered to be "Restricted" instead of Local Machine. HOW CAN I GET AROUND THIS? Correcting the problem from the XP side is complicated and, as yet, I don't understand it.
Thanks for your help,
Gary Hyslop
|
|
|
|
|
Gary Hyslop at home wrote:
I was previously told by one of the "guru's" of this site that this was not a c# issue. That is not correct because C# is the only language that supports Web Page Comments.
Actually, he was correct. This issue has nothing to do with C#, but everything to do with the security settings in Internet Explorer. I haven't installed SP2 yet, so I can't give you an exact answer. But, the first thing to do is double check the Security settings in IE and try relaxing the security level a bit. If it says High, try lowering it to Medium and see what happens.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Actually, that is not a C# feature at all. The Microsoft Visual C# compiler supports generating document comments from the compiler. The comment XML grammar (schema) is not specific to C# at all and can be constructed manually. The VB.NET compiler in "Whidbey" (.NET Framework 2.0) will also be able to generate comments.
The tool in VS.NET to build a web site simply transforms the XML file that is generated for each assembly in your solution, just as NDoc[^] - one of many successful projects I've worked on - and other commercial applications do.
As Dave said, your problem is with Internet Explorer security settings and would not matter one bit if the web site you were viewing was generated from static HTML pages, PHP, ASP, ASP.NET, ol' CGI or anything else.
If you don't understand something, you ask in the right forum. This cannot be corrected on the server side, otherwise that would render security moot. It has to be solved from the client. Like many, many other sites on the web, if there are security settings keeping viewers from displaying the site the way you intend, then you have a support page instructing what they should do and hope they will do it (some may not because they don't understand - which means your directions are clear enough, typically - or because they choose not to). Like it or not, that's why security measures are in place.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi all!
I have a listNode composed by this two parameters
private Bitmap data;
private ListNode next;
And I have a List with some elements. I have to delete several times my list, and I want to free the memory that bitmap occupies, so I made a function in my list to dispose the bitmaps.
current = firstnode;
while(current.next != lastnode)
{
current.data.dispose();
current = current.next;
}
current.data.dispose();
But when I run this functions and with the help of task manager it seems that memory is always increasing. How can I delete imediatly the bitmaps from memory?! Is it possible?!
Thank you all, Sérgio
|
|
|
|
|
You don't have to. You've already .Dispose d the objects, now you have to wait for the Garbage Collector to actually free the memory, and that can take a while. You COULD call GC.Collect() , but it's NOT recommended because you can actually degrade the performance of your app considerably using it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Memory reclaimation is technically "expensive" since it has to lock the references as they are, figure out what is ready to release, do optional stuff like compact, etc. So it is not done unless it is necessary (like low memory) or when it is sure you are idle (often it happens when you minimize) or when you explicitly call System.GC.Collect .
Because you are using a memory managed runtime, you shouldn't care when or how garbage collection happens as long as you Dispose is used correctly. Constantly calling System.GC.Collect slows your application down so if you have to use it please use it in the correct place.
|
|
|
|
|
I have this function QuickFindModules in the dll QuickFind.dll, now I want to use this unmanaged function in my c# code, can somebody show me the best way to do it. Here is the signature.
int QuickFindModules(char* nameList, long bufferLength)
Here is how I pinvoked it..
[DllImport("quickfind.dll", CharSet = CharSet.Ansi)]
public static extern int QuickFindModules([Out]StringBuilder nameList, long bufferLength);
...
StringBuilder nameList = new StringBuilder(512);
long length = 512;
int result = QuickUsbFindModules(nameList, length);
string temp = nameList.ToString();
Was I correct to change the char*, to a StringBuilder. What did I do wrong?
/\ |_ E X E GG
|
|
|
|
|
An unmanaged long is not the same as a managed long . You're pushing the relevent data in your numeric expression off the deep end of the call stack, so it won't be read. What that means is that the unmanaged function implementation will always see 0 as the bufferLength .
You can declare a StringBuilder for a char* , yes. Since a char* is always an Ansi string and you specified such with the DllImportAttribute.CharSet field, you should make sure that QuickFindModules doesn't have ANSI and Unicode support like most Microsoft APIs do (functions ending in "A" or "W" for ANSI and Unicode, respectively). If it does, add "A" to the end and set ExactSpelling to true in your DllImportAttribute declaration.
Finally, never expose P/Invoke methods as public unless the defining type is internal. Callers - even within your own project - should not be able to simply call P/Invoke methods. Remember, P/Invoke calls into unmanaged code. There are ways to actually crash the CLR. You should expose this functionality by encapsulating it into a public method like I have below.
The correct declaration and call should look something like this:
[DllImport("quickfind.dll", CharSet=CharSet.Ansi)]
static extern int QuickFindModules(
[Out] StringBuilder nameList,
int bufferLength);
public string FindModules()
{
int length = 512;
StringBuilder nameList = new StringBuilder(length);
if (QuickFindModules(nameList, length) == 0)
return nameList.ToString();
return null;
} You could also just use a string here, too, and initialize it correctly like so:string nameList = new string('\0', length); .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I don't understand this exactly...
Heath Stewart wrote:
...you should make sure that QuickFindModules doesn't have ANSI and Unicode support like most Microsoft APIs do (functions ending in "A" or "W" for ANSI and Unicode, respectively). If it does, add "A" to the end and set ExactSpelling to true in your DllImportAttribute declaration.
When I set the CharSet to Auto or Unicode , I get a weird (japanese) symbol 啑 and, but when I set CharSet to ANSI, it returns the expected string. So, I guess that means it dosn't have Unicode support. And do you mean if the function name ends in "A" or "W"??? I'm just genreally confused about the above, can you please elaborate on this paragraph?
But, otherwise you words were exactly what I was looking for. Thanks for the help and the example.
And does '\0' mean null?
/\ |_ E X E GG
|
|
|
|
|
I was saying you were right to set CharSet.Ansi since the function is declared using char* (which is always a single byte character). If you use CharSet.Auto or CharSet.Unicode , the string encoding is converted (if CharSet.Auto is set and you're running on Windows NT-based platforms).
The thing about function export spelling is common. ANSI functions are actually declared ending in "A" while Unicode functions are commonly declared ending in "W" like so:
int MyFuncA(LPCSTR lpszParam);
int MyFuncW(LPCWSTR lpszParam);
#ifdef UNICODE
#define MyFunc MyFuncW
#else
#define MyFunc MyFuncA
#endif That's a pretty basic example, though. It's to make sure that the right string encoding is used for the right platform.
Also, '\0' != null. First of all, in C# anything between single quotes is a char (System.Char ). A char is a value type and cannot be null (in .NET 2.0 char? is the same as Nullable<char> and can act like it's null, but value types still can't be null).
'\0' is the null character. This is the common representation in many programming languages, from C to C++ to C# to Perl to Java, etc. This is equal to (char)0 . What I was doing was initializing the string contents to the null character, the equivalent of which in unmanaged code is similar to:
LPTSTR lpszVar = NULL;
lpszVar = (LPTSTR)malloc(512 * sizeof(TCHAR));
_tcsnset(lpszVar, TEXT('\0'), 512);
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Ahh, I understand now.
Heath Stewart wrote:
The thing about function export spelling is common. ANSI functions are actually declared ending in "A" while Unicode functions are commonly declared ending in "W" like so:
I didn't know that, very interesting. I wish the function I was using would have specified (QuickFindModulesA)... That would have made, things easier.
Oh well, everything is cool. thanks for the info.
/\ |_ E X E GG
|
|
|
|
|
I have another question about another function.
int QuickOpen(HANDLE *hDevice, char *devName)
Right now i'm attacking this on like this...
[DllImport("quickfind.dll", CharSet = CharSet.Ansi)]
static extern int QuickOpen(IntPtr handle, [Out]string devName);
Do those conversions look right? Mainly, the HANDLE to IntPtr ...
Then I call it like this...
IntPtr ptr = new IntPtr();
string device = "QUSB-0\0\0";
int result = QuickOpen(ptr, device);
I get an AccessViolationException (.net 2.0 I think). If I switch IntPtr ptr for a StringBuilder ptr , the exception isn't thrown, but the data returned isn't an int it's a string... any idea?
/\ |_ E X E GG
|
|
|
|
|
IntPtr is a value type, and HANDLE is declared in unmanaged code as void* . So, you actually want to declare QuickOpen as:
[DllImport("quickfind.dll", CharSet=CharSet.Ansi)]
static extern int QuickOpen(out IntrPtr handle, string devName); The thing I'm not sure is whether the second param is an [out] parameter. Since the address of a handle (a pointer to a pointer) is passed, I presume its an [out] parameter. The purpose of this function, is it to open a device handle given a name (that's what I'm guessing by the way you're calling it). In that case, my declaration should be correct and you don't need to initialize IntPtr ptr , since it's passed as out ptr like so:
IntPtr ptr;
string device = "QUSB-0\0\0";
int result = QuickOpen(out ptr, device); Finally, why do you keep calling functions named xxxUsbyyy when you declare them as xxxyyy ? If you want to name the P/Invoke methods something different, declare the functions as whatever you want and set EntryPoint to the actual string name (still affected by ExactSpelling , if appropriate) of the exported native function.
Again, never expose P/Invoke methods publicly. You encapsulate them. This is good for another reason: to make otherwise difficult and procedural native APIs easy to use in an object-oriented way.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi,
I am working with a C# web application in which a com object was used. This code was developed by someone else, it was trying to run this project on my laptop. I tried to register the com dll with regsvr32 command, but I was getting an error that says Interop.WINTERTREESPELLINGSERVERLib.dll was loaded, but DllRegisterServer entry point was not found.
DllRegisterServer may not be exported, or corrupt version of dll may be in memory. Consider using PView to detect and remove it.
Can someone suggest me how to solve this problem.
Thanks,
CodeLearner.
|
|
|
|
|
Interop.WINTERTREESPELLINGSERVERLib.dll doesn't have a DllRegisterServer function because it's just the RCW (runtime callable wrapper) assembly .NET uses to actually call the corresponding COM objects.
You have to register the original dll containing the COM objects you want to use with regsvr32.
Regards,
mav
|
|
|
|
|
To extend on what mav said, you should never register the interop assembly (the RCW) anyway. When you develop an RCW, it marshals calls to the original COM server. If you registered the RCW (a la regasm.exe, which is for registering CCWs) it would be the COM server but would contain no implementation. Your COM server is unavailable!
Only register the COM server (.dll, .exe, .ocx, whatever) using regsvr32.exe. If you develop a CCW (COM-Callable Wrapper), register that with regasm.exe that comes with the .NET Framework (i.e., not the SDK but the redistributable Framework).
There's several articles - including one of mine - that discuss this in greater detail.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks for your replies Mav and Heath. I will try what you have suggested.
Thanks,
CodeLearner.
|
|
|
|
|
i hae this task which is to display each client load on the network , the display should be as a diagrame
|
|
|
|
|
Ok, your next step would be to design a solution for your stated goal.
Charlie
if(!curlies){ return; }
|
|
|
|
|
You'll have to have some kind of client application on each of your workstations to collect this kind of information and send it up to a central server. You can't possibly poll each and every computer for its network load constantly. The only other source of information MIGHT be the switch that the clients are connection to.
Also, when/if you write your client app, you'll have to define what consititutes "network load". Packets Sent/Received per second? Bytes Sent/Received per second? per minute? You can't send these statistics to a central server for collection constantly because you'll end up heavily skewing your data. Thus, you'll also have to specify at what interval the clients would have to report in with the server.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|