|
Yes. Your production setup is different to your QA and Dev setup. Beyond that, without any actual details of what isn't working, you're not likely to be able to get much more help.
BTW - this isn't really a C# question.
|
|
|
|
|
HI
I am getting an error "Cannot create an instance of the abstract class or interface Microsoft.Office.Interop.Excel.Application"
Please suggest.
code:
Microsoft.Office.Interop.Excel.Application ExcelObj = new Microsoft.Office.Interop.Excel.Application(); ExcelObj.DisplayAlerts = false;
if (ExcelObj == null)
{
return null;
}
|
|
|
|
|
Do you have reference to the proper version of the Office interop? Do you have Excel?
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
|
I've started a small program for a motorola mc5574 barcode reader. The problem is that I've managed to make it read barcodes but it just read them once and then the readers stops working. Could someone look at my code and tell me where the problem is, thanks alot in advance.
using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows.Forms;
namespace inventering
{
static class Program
{
[MTAThread]
static void Main()
{
Form1 frm1 = new Form1();
Application.Run(frm1);
}
}
}
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Symbol.Barcode2;
namespace inventering
{
public partial class Form1 : Form
{
Barcode2 MyBarcode;
public Form1()
{
MyBarcode = new Barcode2();
MyBarcode.Enable();
MyBarcode.Scan();
MyBarcode.OnScan += new Barcode2.OnScanHandler(myBarcode_OnScan);
InitializeComponent();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == System.Windows.Forms.Keys.Up))
{
}
if ((e.KeyCode == System.Windows.Forms.Keys.Down))
{
}
if ((e.KeyCode == System.Windows.Forms.Keys.Left))
{
}
if ((e.KeyCode == System.Windows.Forms.Keys.Right))
{
}
if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
{
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void label1_ParentChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
void myBarcode_OnScan(ScanDataCollection sd)
{
ScanData scanData = sd.GetFirst;
if (scanData.Result == Results.SUCCESS)
{
textBox1.Text += (scanData.Text + ";" + scanData.Type.ToString());
}
}
private void label2_ParentChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
MyBarcode.Dispose();
this.Close();
}
}
}
|
|
|
|
|
Isn't there a support forum on the Motorola site for this device?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
You showed us a lot of useless code - e.g. those empty event handlers, why do you do that?
Next, I wonder how it works at all...
Even before you call InitializeComponent of the Form, you call the scan method of the BarcodeReader, and its call back function (the OnScan event) is not yet connected...
Add another button for starting the scan, and order things correctly:
public Form1()
{
InitializeComponent();
MyBarcode = new Barcode2();
MyBarcode.OnScan += new Barcode2.OnScanHandler(myBarcode_OnScan);
MyBarcode.Enable();
}
private void btnScan_Click(object sender, EventArgs e)
{
MyBarcode.Scan();
}
|
|
|
|
|
I see only one .Scan() in your program; at the "start".
I'm guessing you need to have a "loop" of sorts, that does a .Scan() each time you need to get a new bar code; it's part of "arming" the device.
I'm sure the "User Guide" has more useful information re: polling / reading from the device.
(I usually use a background worker with a "timeout").
|
|
|
|
|
Hi
How can i download all content of this page :
http://tehran.divar.ir/browse/
I think this is full ajax
Cause when u scroll down the page it reload the new data!
Please Help?
|
|
|
|
|
Depending on which browser you are using, you should be able to use the context or main menu to do a Save As operation.
|
|
|
|
|
thanks for reply!
but the page is Compeletly ajax,so i should scroll down and down to reload the info!
other website act same as this :
http://demos.9lessons.info/load_data_scroll.php[^]
i wanna do that in C#!
thanks in advanced!
modified 10-Aug-14 11:39am.
|
|
|
|
|
Sorry, but I'm not sure what your problem is in terms of C#.
|
|
|
|
|
Why should you get all the content of someone else's site? It's not yours! You should not touch it!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
I am doing it for testing and get info of other website for some use!
|
|
|
|
|
In other words :
What's the best way to scrape a web page that has AJAX/dynamic loading of data?
For example: scraping a webpage that presents 20 images on load, but when a user scroll down the page it loads more images (sort of like Facebook). In such a case how do you scrape all the images, not just the first 20?
|
|
|
|
|
Use Fiddler (or something likewise) to see if it makes a specific call to fetch the data. You're looking for anything that gets loaded by the page using JavaScript and that returns some XML/JSON.
If that fails, then there's always the WebBrowser control
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I am using this code in ASP.net :
<script type="text/javascript">
function getDataS() {
var dd = '{"jsonrpc":"2.0","method":"getPostList","id":1,"params":[1,[["place2",0,[1,1]]],173099135176724],"hash":"decfe7c9183f16efa1291f5131902f7d4ef4ff14"}';
$.ajax({
type: "POST",
url: "http://tehran.divar.ir/browse/json/?tm=1407824648578",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
crossDomain: true,
data: '{"jsonrpc":"2.0","method":"getPostList","id":1,"params":[1,[["place2",0,[1,1]]],173199866315710],"hash":"13210760e20de99b8218be5cc465851fcb6aa74a"}',
cache: false,
processData: false,
success: function(msg) {
if (msg.d != "")
alert('salam');
},
error: function(xhr, errorType, exception) {
var errorMessage = exception || xhr.statusText;
alert("There was an error creating your contact: " + errorMessage);
}
});
}
</script>
I get this error now :
There was an error creating your contact: NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://tehran.divar.ir/'.
|
|
|
|
|
|
Now I process the data synchronized, when recieving the data it deal data.
But I found the data is high frequently recieved, And it waste too much time to process data.
So, I hope to process data asynchronous and ensure the data sequence, not to block the trecieve thread.
I read some arcitles, I get two methods:
1) when recieving data ,right now use " task.factory.startnew..."
2) when recieving data , "enqueue" the data to ConcurrentQueue, According to different data type, i use 8 queues. And the the program is started,
starting 8 threads to dequeue data for every ConcurrentQueue and process it.
public form1(){
Task.factory.startnew(()=>processData(1));
Task.factory.startnew(()=>processData(2));
Task.factory.startnew(()=>processData(3));
Task.factory.startnew(()=>processData(4));
Task.factory.startnew(()=>processData(5));
Task.factory.startnew(()=>processData(6));
Task.factory.startnew(()=>processData(7));
Task.factory.startnew(()=>processData(8));
}
void OndataReceive( string data){
if( ..){
queue1.Enqueue(data);
}
else if(...)
{
queue2.Enqueue(data);
}
....
retutn;
}
void processData(int queueID){
while(true){
ConcurrentQueue queue = getqueue(queueID)
for(int i =0; i < queue.Count; i++){
string s;
queue.TryDequeue(out s);
.....
}
Thread.Sleep(10);
}.
}
I test the above 2). I found CPU and the memory footprint is large ....
How should I solve this problem ?
Thanks
Andrew
modified 10-Aug-14 9:36am.
|
|
|
|
|
Peng2013 wrote: I found CPU and the memory footprint is large Creating a queue and eight threads doesn't hog my machine.
What code are you executing within that thread? Does it allocate memory? How big is the queue on a typical execution?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi All,
I face a problem when run my windows application at the first time( it is take a long time to load - up to 7 seconds) after that when i close it an open again it may take 2-3 seconds, I do some search and find the ngen.exe is the best solution.
Please let me know if the Ngen.exe the best solution or not, if yes how to use it in VS2010, if no what is the best solution.
Thanks All
|
|
|
|
|
NGen is about your only solution.
Everything else comes down to evaluating how you're written your application. For example, having 500 controls on a form is a really bad idea.
|
|
|
|
|
Hi,
The main form is the login form which contains the following controls:
1. 3 text box for login info as the following:
*. User Name text-box.
*. Domain text-box. (UserName= userLogin@Domain)
*. Password text-box.
2. Login button.
3. User Name Label.
4. Password Label.
5. Version Label.
And this form is take load time when open it in the first time.
Please Let me know how to use the NGEN.exe to solve this issue.
Thank You
|
|
|
|
|
This is normally done in your application installer. After your application is installed, you run NGEN on it to get the binaries built. This is normally an automatic option in modern installation builder tools like InstallShield and InnoSetup.
You're also going to improve performance by evaluating what your application is doing on startup, not just counting controls. What is going on in your Program.cs? What is going on in your Form.Load event? How big is your resulting executable when you compile it? Are you doing any database work? Are you using Entity Framework? There is a "warm-up" time when EF first starts.
Stuff like that...
|
|
|
|
|
ngen does help, I´ve used it in the past. However, make sure that your loadup isn´t taking unnecessarely long.
NGen is not a miracle thing and probably is more a workaround than a real solution.
Not sure if it exists still, but in winforms you could have a look at SuspendLayout, ResumeLayout.
Also, in our case a while back, the slow loading was due to thousands and thousands of records that had to be loaded in linked lists. When I convinced the client to change in a small way, the way they were working we could load each list on runtime when (and indeed if) the user needed it. The startup time changed from a few seconds to instantly.
Last thing is that you have to make sure the hardware is sufficient for that version of the .Net framework (and what the application is used for)
hope this helps.
|
|
|
|