|
Sorry, for the wrong link. This [^]is the one.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
excuse me, but I don't feel responsible for that MS link at all...
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Luc Pattyn wrote: excuse me, but I don't feel responsible for that MS link at all
Oops!!! I meant this [^]
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi,
i am trying to make a simple bot using IE automation. i just want to register in one site using my program, but it needs captcha, i am using decaptcher.com for it. it is ok.
after web page openning, in view source of page i get one captcha link. whenever i save this image using c# program, it just redirect and save image is changed as in browser. i think you can understand what i am saying.
Is there any way to save browser image without redirecting? if i just right click in browser, manually then i am able to save image same as.
Any one can help me out??
thanks!
yogesh
|
|
|
|
|
Hello,
I'm programming a new c# application intended to control some hardware trough an ActiveX control. Given that I dont have the actual hardware, my client has provided me with a simulator OCX. The OCX is written in vb6 and it is supposed to read a status word from the registry and to fire an event whenever that word changes (that's accomplished by poling the registry, with a timer control inside the ocx). I've been also given a configurator program, which writes new values to the registry and a test program, which is a form application that consumes the ocx, both of them written in vb6 as well. At this point, everything works perfectly.
The problem arises when I want to use the OCX within a .net winforms application. I've simply referenced the control (visual studio created the wrappers), inserted it in a form and set up the corresponding event handler, which writes the status word to a label control. I've noticed that, very often, the changes in the registry are missed by the control and the corresponding event is not fired. I've confirmed this by using sysinternals regmon to watch the new values being actually written to the registry, and there seem not to be any problem in that matter.
Did anybody have a similar problem?
I would really appreciate any help.
Thanks in advance,
Bernabé
|
|
|
|
|
This is sort of a repost, but I realized after the original post that I was really asking a c# question, not a .NET framework question.
I have the need to change 'this' from one object to another.
Back ground is that I am deserializing some objects that I may already have in memory. If I identify an object as already existing, I want to deserialize directly onto that object, as opposed to deserializing onto a new object and then transfering the values.
1) I can not just use the new object because other objects that were not serialized may have links to the original object, and I don't know them all to change them.
2) The code is already unsafe , so I can't hurt it any more.
Richard
Silver member by constant and unflinching longevity.
|
|
|
|
|
Changing "this" isn't really what you're asking for. If I'm reading this correctly, what you really want to do is overwrite one object's memory with another, so references don't have to be changed.
I would actually advise against this... It would be much easier to do with a simple wrapper class.
public class MyDataObject
{
public SerializableObject Data { get; set; }
public class SerializableObject
{
}
}
So all of your references would be to the instance of MyDataObject, and those would never change... When you deserialize, you set the Data property to the new object, and it works as well as a direct replacement.
If you want to make it more transparent, you can hide the inner object entirely, and make methods and properties in the wrapper that pass through to the inner object.
|
|
|
|
|
I know I can make a variable global to a class. But What I want to do is set a variable under program.cs where "static void Main(string[] args)" Exists. In this class I want to run a initialization process to activate some variables with values I can call from any point in the application. Such as say a System Code. Is there a means of making a variable global to allow for all classes to see the variable.
My current understanding is this is not possible. Only with in classes unless you pass the variable to the other class. Is this correct?
|
|
|
|
|
Terrible idea in general, but you could create a public static variable in a class.
Slightly better: make it a static private variable and expose it as a property.
Cheers,
Vikram. (Cracked not one CCC, but two!)
|
|
|
|
|
You can write a static class to hold such things.
|
|
|
|
|
As Vikram and Piebald suggested, what you're looking for is a static class, which would contain static properties or fields.
If these are program-wide settings, as your post seems to suggest, you can simplify things further (And for that matter, keep it cleaner), by setting up static properties INSIDE the Program class.
public static string SystemSettingThingy { get; private set; }
public static void Main(string[] args)
{
SystemSettingThingy = "MySetting";
}
if (Program.SystemSettingThingy == ...)
One of the main points here is that if it's inside the Program class, you can keep the setter private, so you can ensure that they are never modified. One of the reasons many developers consider globals to be a "bad idea," is that in complex programs, particularly multi-threaded ones, you can have different parts of the app writing to them at different times, and can never really rely on their accuracy.
|
|
|
|
|
Hi,
There is a button on a win form which populates a gridview control with data.
to prevent the UI being locked I am using the Backgroundworker.
The application does not get locked when the data is being retrieved, but it does get locked when inside the event "backgroundWorker1_RunWorkerCompleted" on line:
dataGridView.DataSource = e.Result;
Any thoughts on this please?
Thanks
|
|
|
|
|
Sorry, nothing pops up without seeing some of the code.
I trust the GridView got created before you started the BGW?
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Hi,
your code has vanished again. This was going to be my reply:
(*) I'll put it in when your code is back.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
RunWorkerCompleted is invoked back to the GUI thread, so any code in there will suspend your UI until it finishes.
Some guesses:
1) If you have a lot of data, the grid may be taking a long time to display it. I haven't worked with the WinForms DataGrid in a long time, but if it has any sort of virtualization, turn that on, so it will only try to display the data that's actually visible, not the part that's scrolled off the screen.
2) If it's not a size issue, there may be a property of the result object that's taking a long time to read. When you set the datasource, the grid will read through the results and try to display it, so it will read all the properties it needs... If some of those are complex, it could take a while. If this is the case, try precalculating and caching those properties during the background thread.
|
|
|
|
|
I want to Iterate thru a listBox and write the strings to a file.
I have the following code that worked in VS 2005 but does not compile in VS 2008
StreamWriter f = new StreamWriter(fn);
IEnumerator eEnum = this.mylistBox.Items.GetEnumerator();
if (eEnum != null)
while (eEnum.MoveNext())
f.WriteLine((String) eEnum.Current);
f.Close();
In VS 2008 I get a compile error saying
Using the generic type 'System.Collections.Generic.IEnumerator<t>' requires '1' type arguments
Can someone explain ?
|
|
|
|
|
Hi,
Since .NET 2.0 some interfaces such as IEnumerator exist in non-generic and generic form;
if you have a "using System.Collections.Generic" statement and no "using System.Collections", then the compiker will insist you use IEnumerator<someType>.
If you want to know more, I suggest you read up on "generics".
BTW: you could avoid all this by using a foreach statement, e.g. foreach(object item in myListBox.Items) and then probably work with item.ToString().
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
So I am having a problem. I generated about 100 ISO's files of my movies so I can stream them to my TV. Well now I find out I dont need them in ISO, I need AVI. I am trying to open the ISO and the tool that was used created 2 versions of the same file in the same folder. 1 with 0 bytes and 1 with full bytes. Now here is my question from a C# point of view. I am mounting the ISO as a Drive in Windows and copying all but the 0 byte file out. Works fine in Windows. I want to automate this by having c# Mount the Image and copy the files out. I use the System.IO.Directory.GetFiles and build a array of files. When I go through the array to copy the files, I reference by filename which always get the 0 byte file and not the correct file. I cant delete the 0 byte file as it gets mounted as a CD which is read only. Is there any way to reference a file by some internal ID rather than filename in c#?
private void button1_Click(object sender, EventArgs e)
{
List<string> sFilestoProcess;
List<string> sCopyFiles;
sFilestoProcess = GetISOtoProcess();
foreach (string sFile in sFilestoProcess)
{
Mount(sFile);
sCopyFiles = GetValidFiles();
}
}
private List<string> GetISOtoProcess()
{
List<string> Files = new List<string>();
foreach (string sDirectory in System.IO.Directory.GetFiles(@"D:\"))
{
Files.Add(sDirectory);
}
return Files;
}
|
|
|
|
|
I don't have a direct response for getting the files, but is that pseudo-code or something you are working with? I was wondering if you have code for the Mount() method.
|
|
|
|
|
Dear Sir,
I know its very common problem which has been asked by many people but i did not get any of the persons way of immplementing Remoting as i did so please go through with my steps of my project and provide me solution...
The steps which i used in my program ....
Server Side Code...
my app.config code
<?
xml version="1.0" encoding="utf-8" ?> <
configuration>
<
connectionStrings>
<
add name="VitalDataBaseCon" connectionString ="initial Catalog=pubs ;uid=sa;pwd=success; server=VITAL-17\\VITAL17;integrated security=true"></add>
</
connectionStrings>
<
appSettings>
<
add key ="serverIp" value="192.168.1.17"/>
<
add key ="ServerPort" value="8080"/>
</
appSettings>
<
system.runtime.remoting>
<
customError Mode="on"/>
<
application>
<
service>
<
wellknown mode="SingleCall" type="Vital.DotNet.Server.LogIn,Server" objectUri="LogIn" />
</
service>
<
channels>
<
channel ref="tcp" secure="true" port="8080" impersonate="true" protectionLevel="EncryptAndSign"/>
</
channels>
</
application>
</
system.runtime.remoting>
</
configuration>
Server.cs
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.Data;
using
System.Data.SqlClient;
using
System.Configuration;
using
System.Runtime.Remoting.Lifetime;
using
System.Runtime.Remoting.Channels;
using
System.Runtime.Remoting.Channels.Tcp;
namespace
Vital.DotNet.Server
{
class LogIn:MarshalByRefObject,Vital.DotNet.Server.IvitalServerInterfaces
{
SqlDataAdapter adap;
SqlCommand cmd;
SqlConnection con;
public DataSet retriveData(string authorFirstName,string authorLastName,out bool isSuccess)
{
con =
new SqlConnection("initial Catalog=pubs ;uid=sa;pwd=success; server=VITAL-17\\VITAL17;integrated security=true");
con.Open();
SqlCommand cmd = new SqlCommand("Demoinput", con);
cmd.CommandType=
CommandType.StoredProcedure;
cmd.Parameters.Add(
new SqlParameter("@au_fname",authorFirstName));
cmd.Parameters.Add(
new SqlParameter("@au_lname",authorLastName));
DataSet ds = new DataSet();
SqlDataAdapter adap = new SqlDataAdapter(cmd);
adap.Fill(ds);
if (ds.Tables[0].Rows.Count == 0)
{
isSuccess =
false;
}
else
{
isSuccess =
true;
}
return ds;
}
static void Main(string[] args)
{
Console.ReadLine();
}
}
}
My procedure in pubs data base
create procedure [dbo].[Demoinput]( @au_lname varchar(50),@au_fname varchar(50))
as
begin
select * from authors
where au_lname=@au_lname
end
Interface on server side which has been added on client side as a DLL.
namespace
Vital.DotNet.Server
{
public interface IvitalServerInterfaces
{
DataSet retriveData(string authorFirstName, string authorLastName, out bool isSuccess);
}
}
CLIENT Side Code
client side app.config file
<?
xml version="1.0" encoding="utf-8" ?>
<
configuration>
<
appSettings>
<
add key ="serverIp" value="192.168.1.7"/>
<
add key ="ServerPort" value="9002"/>
</
appSettings>
<
system.runtime.remoting>
<
application>
<
channels>
<
channel ref="tcp" secure="true" tokenImpersonationLevel="Identification" username="" password=""/>
</
channels>
</
application>
</
system.runtime.remoting>
</
configuration>
client.cs
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
Vital.DotNet.Server;
using
System.Configuration;
using
System.Runtime.Remoting.Lifetime;
using
System.Runtime.Remoting.Channels;
using
System.Runtime.Remoting.Channels.Tcp;
namespace
Vital.DotNet.client
{
public partial class Form1 : Form
{
Vital.DotNet.Server.
IvitalServerInterfaces ObjServerSide = null;
bool isSuccess = false;
public Form1()
{
InitializeComponent();
}
private void btnShow_Click(object sender, EventArgs e)
{
try
{
ObjServerSide = (
IvitalServerInterfaces)Activator.GetObject(typeof(IvitalServerInterfaces), @"tcp://192.168.1.17" + ":8080" + "/pop");
ObjServerSide.retriveData(txtAuthorFirstName.Text, txtAuthorLastName.Text,
out isSuccess);
}
catch (System.Runtime.Remoting.RemotingException ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
please help me out from this problem ,i checked this code on remote computer(On LAN) as well as same computer but it doesnot work....
Thanks and regards
AMRITA VISHNOI
hi this is amrita.
Amrita
|
|
|
|
|
No one is going to audit all that unformatted code, (no one will probably do it even if you used the pre tags like you're supposed to)
Post specific issues, not a 'here is my project, fix it' post.
|
|
|
|
|
That is a real work of art, that one can only enjoy from a large distance.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Did you actually READ your post after you hit "Post Message"?? Do you really think anyone is going to scroll through all this empty space? Would you mind cleaning this up so it's readable?
|
|
|
|
|
My eyes! Please, format your code and put it in a <pre> block.
|
|
|
|
|
Especially on weekends i can't read this type of complex code.
Try 2 give code snippets which is well formatted(even having some format) or about the actual problem.
|
|
|
|
|