|
I want to add ip address to my lan card by using Management class' method like GetMethodParameters("EnableStatic") ; but i am unable to assign multiple ips to my lan card is there any way to add ip address programmatic,
like we use advanced tab and then ip settings tab to add another ip address,
or is there any way to call net set command using C#
Thanks in Advance
Regards
|
|
|
|
|
WHY do you want to add IP addresses? What is your purpose? Are these IP addresses yours?
|
|
|
|
|
Yes those ip addresses are of our network, basically i want to ping that ip address if no reply from ping is returned then i want to add that ip as secondary ip of my lan card, just like dhcp but i dont want to use dhcp caz i have specific ips
|
|
|
|
|
Still does not make sense. Adding an IP address to your interface brings you nothing, if the rest of the world doesn't know about it. The only situation where this could be valid is if you have a physical subnet which carries 2 or more logical subnets, where only one of them is DHCP enabled. There may also be uses if you're defining a fault tolerant cluster, where you reserve fallback addresses, but in that case you should reserve them first.
In all other situations, you are going to mess up routing tables, impact your own connectivity, and generally be a nuisance to everyone on the network. Doing it programmatically only guarantees that you're ALWAYS a nuisance.
|
|
|
|
|
He's trying to do what DHCP does.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
There's a thing called DHCP. It's part of the operating system. Use it.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
i have used "EnableDHCP" option but it enabled obtain ip automatically option in tcp/ip settings, but i dont need that. i need to add multiple static ips to my lan card, like DHCP do
|
|
|
|
|
i have done this by another method, i pinged my desired ip and then if that ip pinged fail, i created a batch file to process and assigned that ip to my nic. thanks for your responses, if any one among you guys get the solution to do without executing batch file means through coding.
Regards
|
|
|
|
|
Yeah, but why would you even want to do this? Just pinging an IP to see if it's alive then assigning it to you LAN card gets you nothing. If you're adding IP addresses to the card that are not even part of the subnet that your machine is on just gets you wasting your time since you can't route traffic to that IP if it's not on the correct subnet.
|
|
|
|
|
Actually the purpose to this all scenario is, we work on real time systems in which we are going to arrange high availability of system, like two main servers, two branch servers and etc, there would be only one main server and one branch server running in one time if one of the each server (either branch or main) get fails to respond to its counter part, then another (branch or main server) gets which are already powered on gets connected to its counter part. hope you could understand the scenario
Regards
|
|
|
|
|
So basically, you're trying to kludge together a "poor mans cluster". This is not going to implement a "high availability" system. You've got a couple of problems.
First, neither server is going to have an exact copy, if at all, of the data the other one has. There has to be some kind of syncing going on. There is going to be, in most cases, a substantial lag between one server storing data and the other one picking it up. Depending on the amount of data you have to sync, this can take from minutes to hours to complete 1 sync cycle.
Next, what's you're polling interval going to be for pings? What's you're timeout going to be? How many pings in a row must the server not respond to before it's considered failed? What if both servers are actually running and it's just the ping that didn't come back? Now you've got two servers with the same IP's running and you'll end up with even bigger problems.
Another problem is how are you going to recover the failed server once it's back up? When it comes back up, it should have it's original IP address to match it's DNS record. Now you've got 2 servers going on the same IP address and the one that hold both IP's has no way of automatically determining that the failed server is back up and running because ping's going to that address will get routed back to the "good" server without ever going down the network cable.
At a certain auto manufacturer I used to work for, we did something similar. It was impossible to get the lag time down between the two servers to under 4 hours because they had to sync up hundreds of GB of data constantly. Once server always had a copy of the data that was at least 4 hours old, and probably longer.
IMHO, you should be looking for an actual cluster or single IP solution depending on your requirements. Doing something like this is not scalable at all. If you added more servers, this solution cannot be expanded without rewriting the code to "steal" IP addresses.
|
|
|
|
|
I'm trying to understand what this piece of code does from Prajeesh's Blog
I've never seen a statement with any 'where' statements in the method before
using FluentValidation;
....
public static ValidationResult Validate(K entity)
where T : IValidator, new()
where K : class
{
IValidator __Validator = new T();
return __Validator.Validate(entity);
}
Can you help...???
|
|
|
|
|
Did you ask the author of the blog?
It's time for a new signature.
|
|
|
|
|
yes, no reply as yet, so I thought I'd ask here, seeing as I use CP loads
|
|
|
|
|
The where statements are used to constrain which Types the generic can be used for. So:
Sevententh wrote: where T : IValidator, new()
Means that the type T must inherit from IValidator and must have an accessible constructor that takes no arguments.
Sevententh wrote: where K : class
This states that the type must be a Reference Type, not a Value Type.
|
|
|
|
|
So is the above code wrong? It should be
public static ValidationResult Validate<T>(K entity)
where T : IValidator, new()
where K : class
{
IValidator __Validator = new T();
return __Validator.Validate(entity);
}
As I get the Error: Constraints are not allowed on non-generic declarations, if I use the code from the blog...?
I think I need to wait until the author gets back to me! I run into even more problems if i use this change!!
Thanks for your help tho
|
|
|
|
|
You could try:
public static ValidationResult Validate<T, K>(K entity)
where T : IValidator, new()
where K : class
{
IValidator __Validator = new T();
return __Validator.Validate(entity);
}
But, without more context this is nothing more than an educated guess, so the blog writer will definitly know best.
|
|
|
|
|
Fantastic! that resolved all the other problems I was having with this code
Thanks
|
|
|
|
|
hi guys
how to send file via bluetooth from pc to another device such as phone or pc?
thanks a lot
|
|
|
|
|
|
hello
If my sql statement has multiple lines with comments (i.e. line starting with "//") - how am I going to get it work with Sql cmd and Adapters...? Is there a carriage return escape character ...?
<br />
Cmd = Conn.CreateCommand();<br />
Cmd.CommandType = CommandType.Text;<br />
Cmd.CommandTimeout = 0;<br />
Cmd.CommandText = SomeSQL; << This is multiple lines concatenate to a single string.<br />
ConnFactory = DbProviderFactories.GetFactory("System.Data.SqlClient");<br />
SomeDataSet = new DataSet("MultilineSQL");<br />
SomeTable = new DataTable("MultilineSQL");<br />
SomeDataSet.Tables.Add(SomeTable);<br />
DbAdapter = ConnFactory.CreateDataAdapter();<br />
DbAdapter.SelectCommand = (DbCommand)Cmd;<br />
DbAdapter.Fill(OutputSet, "MultilineSQL");
Thanks
dev
|
|
|
|
|
Are you getting an error while using it now? Could you post a sample of your string query?
|
|
|
|
|
for example
<br />
IF OBJECT_ID('TEMPDB..#SomeTmp) IS NOT NULL DROP TABLE #SomeTmp<br />
CREATE TABLE #SomeTmp<br />
(<br />
a datetime,<br />
b float,<br />
c float,<br />
...<br />
)<br />
// Some comment BLOWS UP HERE <br />
insert into #SomeTmp<br />
exec SomeProc xxxxx
dev
|
|
|
|
|
You probably need some GO 's in there to batch commands up.
IF OBJECT_ID('TEMPDB..#SomeTmp) IS NOT NULL DROP TABLE #SomeTmp
CREATE TABLE #SomeTmp
(
a datetime,
b float,
c float,
...
GO
// insert into #SomeTmp
GO
exec SomeProc xxxxx
GO
|
|
|
|
|
Should the comment be done with -- ?
And when I pass more than one statement in one Command I separate them with semi-colons (; ).
|
|
|
|