|
I have create one file in c drive which and write in it and try to read from window service . Account:Local System, but it Cann't get any thing
Protected Overrides Sub OnStart(ByVal args() As String)
If Not File.Exists("C:\DevLog.txt") Then
EventLog1.WriteEntry("File Not Exist")
Else
Dim sr As StreamReader = New StreamReader("C:\DevLog.txt")
Dim tempstr As String = sr.ReadToEnd
If tempstr = "" Then
Else
EventLog1.WriteEntry("Get File Name")
st = tempstr
End If
sr.Close()
End If
End sub
Thanks in Advance.
|
|
|
|
|
Hi all,
I am new to C# development.I have application in which i need to enable / disbale too many toolbar buttons based on the tree node selection,due to this my screens is flickering to a greater extnet...please suggest me a good approach through which i can avoid the screen flickering.
Thanks in advance.....
|
|
|
|
|
You can use Events to trigger the status of the buttons based on the tree view node.
luisnike19
|
|
|
|
|
Hi All,
I wonder if it is possible to insert data from excel cell to access database by using C#?
I really need some information about this, could anyone provide me this?
Thanks in advance
Nine
|
|
|
|
|
|
Thanks for your quick reply, i'll try it
Thanks again
Nine
|
|
|
|
|
I wrote class library (dll) and this library contains one singleton class. Like this;
public class MyList : List<string>
{
private static readonly MyList m_Instance = new MyList();
private MyList()
{
}
public static MyList Instance
{
get { return m_Instance; }
}
}
Client --- WCF --> Server; add item to MyList class, its properly work.
Another Client --- WCF --> Server; add item to MyList class, its properly work.
But;
I have a thread in server side. If this thread add to item to MyList, clients items not contain in the MyList. Actually main problem is I can't see MyList items which are aded by clients in server thread.
I think this problem related about AppDomain. How can I solve it?
Best Regards...
|
|
|
|
|
Doesn't the server exit the application after the first client does its thing?
|
|
|
|
|
|
You already started a thread for this DO NOT start a new one Now you will get no help.
only two letters away from being an asset
|
|
|
|
|
My WCF Service use TcpBinding and host on windows service. I am not use ServiceBehavior InstanceContextMode... Problem not related about WCF.
I wrote class which is MyClass1, this class in server side. This class have a Start() function.
public void Start()
{
Thread thread = new Thread(new ThreadStart(CheckTablesAreChanged));
thread.IsBackground = true;
thread.Start();
}
private void CheckTablesAreChanged()
{
while (true)
{
... ADD ITEM TO MyLIST CLASS ...
}
}
Start() function call when WCF is hoting like this;
host.Open();
MyClass1.Start();
So this side not related about WCF.
In Client side;
Client --> WCF --> Server --> ADD ITEM TO MyLIST CLASS
For example client add 3 ITEM TO MyLIST CLASS, after that I check MyLIST CLASS count property in "CheckTablesAreChanged()" function, MyLIST CLASS count is 0.
|
|
|
|
|
Don't repost: it's very bad form.
CCC solved so far: 2 (including a Hard One!)
|
|
|
|
|
I have noticed my projects are being generated with a back slash at the end of the company name. In my c# projects it has not been a big issue as I can follow the error message and change the source file. But in a WiX project, it is being generated with the msi file. I would like to find the source of this and correct it.
Where do I find this setting?
Thanks all
|
|
|
|
|
nm, I found it in the computer registration....bah!
|
|
|
|
|
Hi All,
See this code below:
string format = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortTimePattern;
Console.WriteLine("Before Changing:");
Console.WriteLine(format);
Console.WriteLine(DateTime.Now);
Console.WriteLine("After Changing:");
CultureInfo ci = new CultureInfo(System.Threading.Thread.CurrentThread.CurrentUICulture.Name);
ci.DateTimeFormat.ShortTimePattern = "hh:mm:ss tt";
Thread.CurrentThread.CurrentUICulture = ci;
Thread.CurrentThread.CurrentCulture = ci;
format = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortTimePattern;
Console.WriteLine(format);
Console.WriteLine(DateTime.Now);
Console.ReadKey();
Output:<br />
Before Changing:<br />
h:mm tt<br />
10/14/2009 21:47:53<br />
After Changing:<br />
hh:mm:ss tt<br />
10/14/2009 21:47:53
I want the Console.WriteLine(DateTime.Now); will print the date time
now of the application with AM/PM in the end 12h format.
I dont want to use the DateTime.Now.ToString("hh:mm:ss tt") for this action.
How can I change my UI thread/main thread with a CurrentCulture that by default will make the DateTime.Now Time to be with AM/PM(12h time) at the end??
Thanks!
Ronen
|
|
|
|
|
I've just copied and pasted you code and it does exactly what you want
|
|
|
|
|
Hi,
After the change you see in your console AM/PM????
|
|
|
|
|
|
I also tried this (EN-gb) and it works fine. Maybe your default Culture affects this in some way.
|
|
|
|
|
Hi
I looking to implement a method in C# which I can pass a list object of any type, serializes the object into xml and returns an xml document.
My problem is on this interface, because I am looking to pass any list object of any type that is being passed. Is there a way in which I can declare a list that can be of any type and on the declaration xmlserialize that the list object can be of any type?
Thanks
|
|
|
|
|
Read this[^], it should hopefully answer your question.
|
|
|
|
|
Thanks, but not quite.
Perhaps I need to explain a little more, the method needs to cope with any list object type. So, if I have a List Object of type string, I need it to return an xml document, but the next List Object I'll next pass it could be an object type and again I need it to return an xml document.
What I am trying to do is have one method to serialize a number List objects of different types to xml in order to handle else where in an application, but of course I do not wish to repeat the code hundred of times.
|
|
|
|
|
Since XML is string based it doesn't matter what you pass in, it will always be a string value in the XML document. What issue are you having difficulty with?
only two letters away from being an asset
|
|
|
|
|
I get you but the approach suggested should work...
I tried these two methods (serializing to file but it could be a memory stream or whatever) and it works
public void Serialize<T>(List<T> list)
{
XmlSerializer xs = new XmlSerializer(typeof(ListHolder<T>));
using (StreamWriter writer = new StreamWriter(@"c:\test.xml"))
{
xs.Serialize(writer, new ListHolder<T>(list));
}
}
public List<T> DeSerialize<T>()
{
List<T> result = null;
XmlSerializer xs = new XmlSerializer(typeof(ListHolder<T>));
using (FileStream fs = new FileStream(@"c:\test.xml", FileMode.Open))
{
XmlReader reader = new XmlTextReader(fs);
ListHolder<T> listHolder = (ListHolder<T>)xs.Deserialize(reader);
fs.Close();
result = listHolder.List;
}
return result;
}
Using this supporting class...
public class ListHolder<T>
{
public ListHolder()
{
list = new List<T>();
}
public ListHolder(List<T> list)
{
this.list = list;
}
private List<T> list;
public List<T> List { get { return list; } }
} To test I used this code:
List<int> toSerialize = new List<int>(3) { 1, 2, 3 };
Serialize<int>(toSerialize);
List<int> deSerialized = DeSerialize<int>(); The xml file is created perfectly and the list is deserialized perfectly from it too.
|
|
|
|
|
I am trying to send an email from Windows Application (C#) through my host email but getting the following error message after a long time waiting:
ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x3b3f18 to COM context 0x3b3da8 for 60 seconds.
The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing
a very long running operation without pumping Windows messages. This situation generally has a negative performance
impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time.
To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives
(such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
here is my code:
string msg = null;
msg = Environment.NewLine + Environment.NewLine;
msg += "TICS User Details" + txtInternetCafe.Text + Environment.NewLine + Environment.NewLine;
msg += "Cafe Name: " + txtInternetCafe.Text + Environment.NewLine + Environment.NewLine;
msg += "Country: " + cboCountry.Text + Environment.NewLine + Environment.NewLine;
msg += "Telephone: " + txtTelephone.Text + Environment.NewLine + Environment.NewLine;
msg += "Email Address: " + txtEmailAddress.Text + Environment.NewLine + Environment.NewLine;
msg += "CPU Serial: " + get_cpu_serial() + Environment.NewLine + Environment.NewLine;
MailAddress mail_from = new MailAddress(txtEmailAddress.Text, txtInternetCafe.Text);
MailAddress mail_to = new MailAddress("EMAIL REMOVED", "JassimRahma.com");
MailMessage mail_message = new MailMessage();
mail_message.From = mail_from;
mail_message.To.Add(mail_to);
mail_message.Subject = "TICS - Registration Request";
mail_message.IsBodyHtml = true;
mail_message.Body = msg;
SmtpClient smtp_client = new SmtpClient("mail.mishkah.org");
NetworkCredential login_info = new NetworkCredential("EMAIL REMOVED", "xxxxx");
smtp_client.UseDefaultCredentials = false;
smtp_client.Credentials = login_info;
smtp_client.Send(mail_message);
mail_message.Dispose();
|
|
|
|