Stefan Prodan
Posts
-
Lenghty operations -
Comunicating with service application.If the windows application is on the same PC as the service best is to use .NET Remoting with IPC protocol. Registering a IPC port will not make the firewall jump and you can use binary serialization.
-
C# reverse engineering, [modified]In VS.NET 2005 right click a .cs file and chose "View Class Diagram".
-
IIS6 with .NET Framework 1.1 and 2.0 at the same time?? can i do that? -
Make MarshalByRefObject thread-safeI am hosting in a windows service a remoting object as singleton, I want to make sure that clients calls are thread-safe. Here is the class definition:
[Synchronization(true)] public class Service : MarshalByRefObject, IService
My question to you is if the Synchronization attribute is a good thing or should I use locks inside every Method of the Service class. -
problem in implementing sql server connection in windows serviceIn VS.NET go to Debugger menu and select the 'Attach process', you'll be able to debug the service.
-
image to string and backwords..Here is my code, I've test it with BMP but I think it will work with any image format.
using System.IO; using System.Drawing; using System.Runtime.Serialization.Formatters.Soap;
Image image = Image.FromFile(file); // load some image SoapFormatter formater = new SoapFormatter(); byte[] obj; using (MemoryStream ms = new MemoryStream()) { formater.Serialize(ms, image); obj = ms.ToArray(); } string str = Convert.ToBase64String(obj); // convert byte[] to string byte[] bytes = Convert.FromBase64String(str);// convert string to byte[] Image newImage; using (MemoryStream ms = new MemoryStream(bytes)) { newImage = (Image)formater.Deserialize(ms); } newImage.Save(file + ".bmp");
-
help me about speed of loading data ...Did you write code to load the data or you've drag/drooped in VS.NET a connection/dataset and so on?
-
Get Application directory from console programThat's easy, just use
AppDomain.CurrentDomain.BaseDirectory
to get the running directory and add to it your console application name and you have a path just like Application.ExecutablePath. -
image to string and backwords..Look at the BitConverter class, BitConverter.ToString Method (Byte[]).
-
Bad Request!Get ProcessExplorer or a similar tool and monitor the asp.net process that is running your webservice, I think that IIS is restarting the process due to large amount of RAM usage. I got the same error uploading large files by calling a webservice, chunk by chunk. A solution is to use free the memory from time to time by calling the Garbage Collector.
-
Concept of Thread.BeginCriticalRegion()Thread.BeginCriticalRegion does not block the abort command, and by the way the first rule that I've learned about multi-threading is to never use Abort, there are tones of other ways to stop a thread gracefully. Here it is an alternative to Thread.Abort: http://stefanprodan.wordpress.com/2007/03/22/stop-threads-gracefuly[^]
-
Button.Text has no effect?This is not a strange behavior, your should start a new thread to do the time consuming work and on the finish event of the tread set the btnGo.Text = "Start".
-
Passing Parameters to a running threadYou can make a static class that exposes properties that you can set/get from different threads. So when your activated event fires the thread will get the value of the property. Because you are using a multi-threading application the static properties should use
lock {...}
inside the get/set. -
Suggestion for C# compatible languageheavy load of optimization = ANSI C :)
-
how to encode string in serializationWell here it is a function that i use to encode strings in XML files:
/// /// Convert To Base64 /// /// clean text /// 1(Unicode) 2(ASCII) 3(UTF7) 4(UTF8) /// Base64 string public static string ToB64(string text, Int16 type) { string rez = null; switch (type) { case 1: //Unicode rez = Convert.ToBase64String(Encoding.Unicode.GetBytes(text)); break; case 2: //ASCII rez = Convert.ToBase64String(Encoding.ASCII.GetBytes(text)); break; ase 3: //UTF7 rez = Convert.ToBase64String(Encoding.UTF7.GetBytes(text)); break; case 4: //UTF8 rez = Convert.ToBase64String(Encoding.UTF8.GetBytes(text)); break; } eturn rez; }
and to decode:/// /// Convert From Base64 /// /// encrypted text /// 1(Unicode) 2(ASCII) 3(UTF7) 4(UTF8) /// clean text public static string FromB64(string text, Int16 type) { string rez = null; switch (type) { case 1: //Unicode rez = Encoding.Unicode.GetString(Convert.FromBase64String(text)); break; case 2: //ASCII rez = Encoding.ASCII.GetString(Convert.FromBase64String(text)); break; case 3: //UTF7 rez = Encoding.UTF7.GetString(Convert.FromBase64String(text)); break; case 4: //UTF8 rez = Encoding.UTF8.GetString(Convert.FromBase64String(text)); break; } return rez; }
-
C# to extractI gues you need a Zip like utility. There is a free zip lib made in C# here icsharpcode.net
-
HTTP ListenerYou can do it in .NET really easy. All you need to do is a Web Service, the site will call a method on that web service and pass the data, and then the web service will insert into Oracle.
-
How to change MAC address?I need this feature for a LAN application, I can provide to the user an interface with IP, Mask, Gateway and DNS configuration but not the MAC, so if anyone tryed this in C# please let me know.
-
How to change MAC address?Anyone knows how to change the MAC of the first Network adapter using C#? Thanks