|
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'.
|
|
|
|
|
Hmmmm i got it thnx!....but then why we register dll to system32 using regsvr32 i was in notion that to use as a part of window(i was so wrong!).....
|
|
|
|
|
So an application that uses the objects in that .DLL can instantiate them without knowing the filename and path of the .DLL hosting it. Regsitration only works for COM-based .DLL's. Library and resource .DLL's don't use registration at all.
|
|
|
|
|
cool i got it..in short u meant for reusability to avoid long messy procedures...........
Thnx alot
|
|
|
|
|
Below are the applicable code snippits. Basically from my class poker I update a Global Variable Int from the class GlobalVar. I then want to update the lblwinnings on frmMain from my poker class.
namespace vdp
{
partial public class frmMain: Form
{
public string credits { set { this.lbl.winnings.Text = value; } }
}
class poker
{
public static void Results()
{
frmMain Form1 = new frmMain();
Form1.credits = Convert.ToString(GlobalVar.Winnings);
}
}
}
modified on Wednesday, October 14, 2009 12:26 PM
|
|
|
|
|
This class shouldn't know anything about, nor care about, any Label control on any form. What it should be doing is using a delegate that the parent form can use to get notifications from this class and the form can decide whether or not to update its own label control.
|
|
|
|
|
Thanks, unfortunatley if I understood how to accomplish what you suggested I wouldn't of had to ask the question. I've tried vairous methods, including using a delegate. However I'm still stuck. Examples would much appriciated, thanks so much for your time.
|
|
|
|
|
Here's a quick example of how it could be aproached using an event. An event is a delegate in disguise!
using System;
using System.Windows.Forms;
namespace vdp
{
public partial class FormMain : Form
{
private Poker poker;
private int credits;
public FormMain()
{
InitializeComponent();
poker = new Poker();
labelWinnings.Text = "0";
poker.UpdateWinnings += new EventHandler<WinningsEventArgs>(poker_UpdateWinnings);
DoubleClick += new EventHandler(FormMain_DoubleClick);
}
void FormMain_DoubleClick(object sender, EventArgs e)
{
poker.PlayGame();
}
void poker_UpdateWinnings(object sender, WinningsEventArgs e)
{
AddToCredits(e.Winnings);
}
public void AddToCredits(int winnings)
{
credits += winnings;
labelWinnings.Text = credits.ToString();
}
}
public class Poker
{
public event EventHandler<WinningsEventArgs> UpdateWinnings;
public void PlayGame()
{
OnUpdateWinnings(new WinningsEventArgs(1000));
}
protected virtual void OnUpdateWinnings(WinningsEventArgs e)
{
EventHandler<WinningsEventArgs> eh = UpdateWinnings;
if (eh != null)
eh(this, e);
}
}
public class WinningsEventArgs : EventArgs
{
public WinningsEventArgs(int winnings)
{
Winnings = winnings;
}
public int Winnings
{
get;
private set;
}
}
}
|
|
|
|
|
Thanks, I typed it verbatium into my exisitng code, like before, it compiles and runs fine. But alas the label still doesn't update
|
|
|
|
|
Then you have something wrong with your event raising, subscription or handling. You need to learn/understand how these work to use them successfully.
Here is a brief code snippet with comments which should give you an overview. If this isn't enough, google or search here on CodeProject... there are lots of articles/blogs on it. I even have an article on here covering this subject in some depth - Events Made Simple[^]
public class TestClass
{
private ClassWithEvent classWithEvent;
public TestClass()
{
classWithEvent = new ClassWithEvent();
classWithEvent.Event += new EventHandler(classWithEvent_Event);
}
void classWithEvent_Event(object sender, EventArgs e)
{
Console.WriteLine("Event Rased!");
}
}
public class ClassWithEvent
{
public event EventHandler Event;
protected virtual void OnEvent(EventArgs e)
{
EventHandler eh = Event;
if (eh != null)
eh(this, e);
}
public void PerformEvent()
{
OnEvent(EventArgs.Empty);
}
}
|
|
|
|
|
ok, I got that part to work..I had the following line of code: Poker poker = new Poker(); before I called a method in my poker class from my frmMain class that had to be removed
|
|
|
|
|
Hello,
I was wondering if there is a way to perform a simple left mouse click anywhere on the screen?
Thanks.
|
|
|
|
|
The last time I tried this (about 4 years ago) it was complicated, assuming you want to move the mouse outside the bounds of the executing app. I had to hook the Windows Queue and intercept / process the mouse messages.
There is an article for something similar here
http://blogs.msdn.com/toub/archive/2006/05/03/589468.aspx[^]
I'm not sure this will work on OSs newer than XP, or even if this is the best way to go about it. Hopefully one of the opther CPians will have a better suggestion
CCC solved so far: 2 (including a Hard One!)
|
|
|
|
|
Hi,
yes you can click anywhere using P/Invoke and calling
[DllImport("user32.dll", CallingConvention=CallingConvention.StdCall, SetLastError=true)]
public static extern IntPtr SendInput(int count, ref INPUT input, int size);
I've built a little class that moves and clicks any way I want.
Of course clicking at (x,y) in screen coordinates assumes the thing you want to click really is there (the user or some code may move objects around) and is not covered by something else.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
I create class library, its name "SharedObjects". This library contain one class, its name "Sample". Class "Sample" contain following codes;
private static readonly Sample m_Instance = new Sample();
private Sample()
{
}
public static Sample Instance
{
get { return m_Instance; }
}
public string Name { get; set; }
Sample class is singleton, and have one property which is "Name". I add two Windows Forms Application to my solution which are "Win1" and "Win2".
In Win1 contain following code;
Sample.Instance.Name = "ABC";
MessageBox.Show(Sample.Instance.Name);
In Win2 contain following code;
MessageBox.Show(Sample.Instance.Name);
My problem is, I run Win1 code its properly work but after that I run Win2 do not show "ABC", its show empty string.
I think my problem is related about application domain, but I can't solve my problem. I wrote CrossAppDomainSingleton class but I can't solve my problem.
Please help me...
|
|
|
|
|
Yes you have found expected behavior. The two applications are in separate AppDomains with separate memory spaces. Typically when sharing information between apps you would set up an intermediary source, like a database or a message queue. You could also create a WCF or Remoting service to share the data between apps
only two letters away from being an asset
|
|
|
|
|
Aoooo, actually my project already use WCF. Real senario like this, SharedObjects is inherit from generic list and this dll is shared dll, its mean using server-side and client-side. Run thread on application server when WCF service hosting and use "SharedObjects" dll.
Client use this dll, two times in one operation. First is using in client-side, second is server side via WCF. So add data to SharedObjects list. Its properly work. But another client want to use SharedObjects list in server side via WCF, SharedObjects list count is zero, main problem is this.
|
|
|
|
|
I don't understand your whole server side and client side breakdown. All you need is the WCF service, once instantiated the client has a proxy, an instance of the class, no need for a client copy also. What are you using with the WCF service?
only two letters away from being an asset
|
|
|
|
|
Sorry, I fix my question and ask again in the form.
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...
|
|
|
|
|
You still haven't answered the question. How have you constructed the WCF service? What InstanceMode are you using? What persistance mechanism are you using? How much do you really understand about WCF and using it?
only two letters away from being an asset
|
|
|
|