|
|
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();
|
|
|
|
|
|
i did unchecked the Thrown checkbox but now I am getting:
System.Net.WebException: Unable to connect to the remote server---->
System.Net.SocketsException: No Connection could be made because the target machine actively refused it 208.113.200.10:25
what does this mean? and how to fix?
|
|
|
|
|
This is your network connectivity issue. Try to debug and check in which line it throwing the exception.
jrahma wrote: System.Net.SocketsException: No Connection could be made because the target machine actively refused it 208.113.200.10:25
This means, you system is not able to connect with specifed ip.
|
|
|
|
|
Hello Everyone,
I have a very small problem which I cant seem to fix. The following is the code which validates an XML file against a Schema. As the XML file gets parsed, if there is an XMLException in the XML file, the error message indicates the error and outputs the message along with the Line and position. But if there is a XMLSchemaException, it indicates the error but does not tell me the line and position number.
try
{
XmlDocument doc = new XmlDocument();
doc.Load(strXML);
string xmlFrag = doc.InnerXml;
XmlParserContext context = new XmlParserContext(null, null, "", XmlSpace.None);
reader = new XmlValidatingReader(xmlFrag, XmlNodeType.Element, context);
reader.ValidationType = ValidationType.Schema;
myschema.Add("http://tempuri.org/dsMinistryH1N1Export.xsd", strXSD);
reader.Schemas.Add(myschema);
while (reader.Read())
{
}
output.Text = ("Completed Validating " + strXML);
}
catch (XmlException XmlExp)
{
output.Text = ("XMLException " + XmlExp.Message);
}
catch (XmlSchemaException XmlSchExp)
{
output.Text = ("XMLSchemaException:" + XmlSchExp.Message);
}
catch (Exception GenExp)
{
output.Text = ("Exception " + GenExp.Message);
}
Note: I have tried using XmlSchExp.LineNumber and XmlSchExp.LinePosition - The problem is I need the user to be able to fix the error in the XML file, not the Schema File. So how do I output the Line/Position of where the error is in the XML file once the reader catches the XML schemaException. I hope I am clear about my question. Thanks in advance for any help.
|
|
|
|
|
Hello everyone...
Im a bit new to c#....
I have written simple program which produces beeps in every 10min i want it to be converted to dll and i wanna use it on my system so that it beeps in every 10min.....
I know it can be easily done with exe file of that project but i wanna use dll and register in system32 and make a part of windows.....
all i know that it's done with csc compiler but what have to be written in /t:library......
ex....
csc /t:library simpledll.cs
it says missing reference or assemblies.....
Thnx....
|
|
|
|
|
You appear to be under the mistake belief that just because you register the .DLL that the code automatically runs. Such is not the case. .DLL's have to be loaded by another process and explicitly execute the code contained within.
You can make this a .DLL all you want - nothing is going to happen. And it does NOT "become part of Windows" when you register something.
You have to leave this as an .EXE, or at least an .EXE that loads and runs the code in the .DLL.
|
|
|
|
|
i know it can't run on own.....i tried to register with regsvr32......................
what is the exact procedure can u please tell...in google im quite messed up....
|
|
|
|
|
No it can't. An exe somewhere has to call the code contained in the dll. This could be a scheduled task, a service or whatever but a dll is incapable of running 'standalone'.
|
|
|
|