|
The other party app receiving XML without any attributes. If any attributes are there that throwing exception
|
|
|
|
|
Then use the error handler of the serializer to do a fix-up.
Or tell the receiving app to fix their class constructor.
You don't like your options? Life is hard and you die.
|
|
|
|
|
Hi all,
I am trying to make a program that locks the computer every 1 hour, and display a window to the user, this should have a question , and textbox to answer the question.
I don't how to do this exactly, i tried to make a code to change the password of the user to be the answer of some question and the password hint to be the question, but i failed.
I don't know if this method works or not, if you can help me to do this, then i am grateful
However, if you know any other techniques to do this, please suggest
|
|
|
|
|
You're trying to do what?!??? Seriously, why are you trying to do this?
This space for rent
|
|
|
|
|
I think you know the answer to your question.
|
|
|
|
|
It has to be asked. There's a one in 10 billion chance it might be legit.
This space for rent
|
|
|
|
|
Yep, and the population of the planet is somewhat less than ten billion....
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
|
Was your hour up when you were writing that post?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
You create your own desktop[^], and set it to the foreground. Next you run your GUI in that Desktop, and close the desktop again if the requirements are met.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I am doing this in my own computer, and i will make a copy of this application on my children's PC, the purpose of this software is to encourage them to gain knowledge.
The main problem, is that i don't know how to make my program on top of everything , and make the user unable to get rid of it , until solving the question
|
|
|
|
|
Your program can't be on top of everything, unless it is running as a screensaver. Other applications will fight for the right of being the topmost.
The login-screen and the desktop are "desktop" objects, capable of showing applications. You'd need to create one (example here[^]) and then run your application in that new desktop. There's bound to be an article on CodeProject that shows "desktop switching", which would be a good place to start*
No, not easy if you're new to .NET.
--edit
*) Found it; Desktop Switching[^]. Contains a desktop-class that hides the complicated stuff.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
In my project, there is a folder called "Resources" and there is an Excel file called "query.xlsx" inside that folder.
I try to load Excel file like this :
ExcelFile ef = ExcelFile.Load(HttpContext.Current.Server.MapPath("~/Resources/query.xlsx"));
And I get this exception :
HttpContext.Current.Server = 'HttpContext.Current.Server' threw an exception of type 'System.NullReferenceException'
How can I load that Excel file properly? Thanks.
|
|
|
|
|
MapPath is only used with websites: it "communicates" with IIS and converts "~" into the root folder fro your site.
For non-website based applications the HttpContext and the Server don't exist, so you get a null reference.
If the file changes at all, then consider storing it elsewhere: Where should I store my data?[^] will help.
If it doesn't change at all, then embed it as a resource to your application, and use Properties.Resources to fetch the file data.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I want to ping a list of IPs but it's not working.
I already use this function in console app and it was working.
<pre>string[] addresses = { "192.168.1.2", "192.168.1.3", "192.168.1.4" };
void show()
{
List<Task<PingReply>> pingTasks = new List<Task<PingReply>>();
foreach (var address in addresses)
{
pingTasks.Add(PingAsync(address));
}
Task.WaitAll(pingTasks.ToArray());
int i = 0;
listView1.Clear();
listView1.Columns.Add("Device IP", 100);
listView1.Columns.Add("ping", 60);
foreach (var pingTask in pingTasks)
{
string[] A = { addresses[i], pingTask.Result.RoundtripTime.ToString() };
ListViewItem item = new ListViewItem(A);
listView1.Items.Add(item);
}
}
Task<PingReply> PingAsync(string address)
{
var tcs = new TaskCompletionSource<PingReply>();
Ping ping = new Ping();
ping.PingCompleted += (obj, sender) =>
{
tcs.SetResult(sender.Reply);
};
ping.SendAsync(address, new object());
return tcs.Task;
}
please helpppppppppp!
|
|
|
|
|
Don't post in multiple places - it duplicates work and that annoys people.
You already have this in QA, so leave it there!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi folks, looking for some help here, I need to make a Rest request.
I'm using Microsoft studio 2015.
I need to include header i.e Content-type: application/json and pass in 2 parameters.
Any pointer or help much appreciated.
|
|
|
|
|
|
I'm working on dataGrid Save content based on SQL Server data, C # smart devices and I have all the code I do not make mistake but not save data
string partDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
string partBD = System.IO.Path.Combine(partDir, "embarque.sdf");
string connectionstring = string.Format(@"DataSource={0}; Password ='root'", partBD);
try
{
using (SqlCeConnection con = new SqlCeConnection(connectionstring))
{
string ConsultaSQL = "INSERT INTO ENVIO VALUES(@RAID, @NPARTE, @CANTIDAD, @VENTANA, @LIDER, @FECHA)";
foreach (DataRow row in dt.Rows)
{
SqlCeCommand cmd = new SqlCeCommand(ConsultaSQL, con);
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@RAID", Convert.ToString(row["Raid"].ToString()));
cmd.Parameters.AddWithValue("@NPARTE", Convert.ToString(row["Nparte"].ToString()));
cmd.Parameters.AddWithValue("@CANTIDAD", Convert.ToString(row["Cantidad"].ToString()));
cmd.Parameters.AddWithValue("@VENTANA", Convert.ToString(row["Ventana"].ToString()));
cmd.Parameters.AddWithValue("@LIDER", Convert.ToString(row["Lider"].ToString()));
cmd.Parameters.AddWithValue("@FECHA", Convert.ToString(row["Fecha"].ToString()));
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
MessageBox.Show("Datos Agregados");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
|
|
|
|
|
How do you know it's not saving the data? I see that you are using the executable path for the location of the database, so I assume that you have it in a root folder of your project. So, when you build, the file is (in all probability) copied over the one in the executable location. You have two possible fixes:
1. Change the file property in Visual Studio so that it only copies when newer.
2. Don't use the executable location.
Option 2 is the better choice because you won't be able to update the data in the database once you install it into a protected folder such as inside Program Files. You should look to use AppData to store your file instead.
This space for rent
|
|
|
|
|
As Pete says, the database location is probably relevant here - you should never store data in the app folder as it tends to work in development, but fail in production. The reason for that is that in production it's installed under "Program Files" (or its x86 equivelant) which is protected from changes by the system to help prevent virus activity.
Have a look here: Where should I store my data?[^] - it shows some better places, and how to access them.
In addition, it's a poor idea to just us an anonymous INSERT - you should list the columns in the order you are going to INSERT them as this means your code is more resilient to changes in your DB. Use:
INSERT INTO ENVIO (Raid, Nparte, Cantidad, Ventana, Lider, Fecha) VALUES (@RAID, @NPARTE, @CANTIDAD, @VENTANA, @LIDER, @FECHA) (Or similar) instead.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I have a rather complicated class describing an xml structure, I've been using the .net XmlSerializer and its has worked for almost all of my purposes except for one very important kink.
I have an element deep in my xml object where the rules are no more. The element has text and xml elements mingled in with the text. Like so.
<KnownElement>
Here is some text <c>This is important text</c> here is some more text <c>Yet more important text stuff</c> more text
</KnownElement>
I need to be able to know at the very least, where the text is and where the important text is (which can assume different tags by the way, so need to know which tags they assume too), in regards to each other.
This is as close as I've gotten to a solution.
public class KnownElement
{
[XmlAnyElement]
public XmlElement[] DocumentNodes { get; set; }
[XmlText]
public string[] Text { get; set; }
}
This allows me to retrieve the nodes for the important text as well as the text that isn't in a node, but inside the KnownElement. The only problem is I have no idea in which order they're all are in the grand scheme. The DocumentNodes property returns an ordered enumeration of the nodes (important text) inside KnownElement, and the Text property returns an array of strings of which are an ordered occurrence of text separated by nodes.
This is neat, but say I have only one node, and one text... I have no idea if the text came before or after the node.
Is there anyway to get the desired effect without me throwing up a xmlreader or something like that...? I would hate to iterate through the HUGE structure this little bit is found within.
|
|
|
|
|
"If thine eye ("c" in this case) offends thee, pluck it out!".
Do a "change all" on any
" <c>" and
"</c> " to some other harmless tag or token.
(These should have been "HTML escaped")
|
|
|
|
|
I have a Bat file that I can load outside of C# but wanted to have it inside of C# to be more secure(load it inside of the exe of C# code).
I can't wrap it out my head on how you would load a batch file inside from C#. Here is my code on how to load it outside of C#:
try
{
var newProcessInfo = new System.Diagnostics.ProcessStartInfo();
newProcessInfo.FileName = @"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe";
newProcessInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
newProcessInfo.Verb = "runas";
newProcessInfo.Arguments = @"-executionpolicy unrestricted -Command "".\power\gwx\uninstallgwx.bat""";
System.Diagnostics.Process.Start(newProcessInfo);
MessageBox.Show("Windows 10 Updater uninstalled");
}
catch
{ }
|
|
|
|
|